我想充气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 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