はR.id.catText
と膨らんでいますが、それを膨張させても表示されません。私がを膨らませてR.id.assets
(コンテナ)の場合、両方の要素がうまく表示されます。私はちょうどコンテナを望んでいない。どうすればいいですか膨らませるR.id.catText
を膨張させずにR.id.assets
を付けないでください。膨らんだビューと要素を膨らますと
また、を膨らませてR.id.catText
をオブジェクトに追加できますか?例えば。
TextView catText = inflater.inflate(R.id.catText);
someView.addView(new catText());
私のコード:
LinearLayout myRoot = (LinearLayout) findViewById(R.id.assets);
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.assets, myRoot, false);
私のスタイル:XMLレイアウトからViewオブジェクトを作成
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:padding="50px" android:id="@+id/assets">
<TextView android:id="@+id/catText" android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ff0000"></TextView>
</LinearLayout>
私はこの質問に答えると信じています。 – Jacksonkr