###前提・実現したいこと
こんにちは、タイトルの通りなのですが、xmlとカスタムビュー?を両立したいです。
詳細は下にあります。
###該当のソースコード
java
1FrameLayout fl = new FrameLayout(this); 2 this.setContentView(fl); 3 fl.addView(sc); 4 setContentView(R.layout.activity_game);
xml
1<?xml version="1.0" encoding="utf-8"?> 2<android.support.percent.PercentFrameLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 xmlns:app="http://schemas.android.com/apk/res-auto" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 android:gravity="top"> 8 <com.gmail.archerygame.Game.Screen 9 android:id="@+id/sc" 10 android:layout_width="wrap_content" 11 android:layout_height="wrap_content" 12 /> 13 <TextView 14 android:id="@+id/powertext" 15 android:layout_width="wrap_content" 16 android:layout_height="wrap_content" 17 android:text="power" 18 app:layout_marginLeftPercent="25%" 19 /> 20 <TextView 21 android:id="@+id/staminatext" 22 android:layout_width="wrap_content" 23 android:layout_height="wrap_content" 24 android:text="stamina" 25 app:layout_marginLeftPercent="25%" 26 app:layout_marginTopPercent="10%" 27 /> 28 <TextView 29 android:id="@+id/timer" 30 android:layout_width="10dp" 31 android:layout_height="10dp" 32 android:text="Timer" 33 android:layout_gravity="right" 34 /> 35 36</android.support.percent.PercentFrameLayout>
###発生している問題・エラーメッセージ
エラーメッセージはありません。
上記のコードのscはViewを継承したクラスなのですが、それを実装しようとしています。と同時にacrivity_game.xmlのデザインも導入しようとしています。そうするとどちらかしかセットできません。
両方セットする(重ねる)方法があれば教えてください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/14 10:59
2017/04/14 11:02
2017/04/14 11:33
2017/04/14 11:56
2017/04/14 12:14
2017/04/14 12:44
2017/04/14 12:54
2017/04/14 12:59
2017/04/14 13:05
2017/04/14 13:07 編集
2017/04/14 13:15
2017/04/14 13:28
2017/04/14 13:45
2017/04/14 13:50
2017/04/14 14:28
2017/04/14 14:59 編集
2017/04/14 16:26
2017/04/15 06:36
2017/04/15 08:06
2017/04/15 09:24
2017/04/15 09:41