Gna*_*m R 13 user-interface android view android-inflate android-tablelayout
我正在创建一个tableLayout [以XML格式给出]
添加表行[以XML格式创建并在Java中膨胀]
还在表格中添加2个textview [以XML格式创建并在JAVA中进行膨胀]
我只能获得背景和文本颜色,但不能获得宽度,高度和边距等布局属性来获取表格视图.
Cha*_*ted 50
首先声明你的inflater.
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
Run Code Online (Sandbox Code Playgroud)识别并扩展您在当前视图上投影的新视图.
View view = inflater.inflate(R.layout.new_layout,null);
Run Code Online (Sandbox Code Playgroud)您可能希望将新的膨胀视图添加到布局中.
main.addView(view);
Run Code Online (Sandbox Code Playgroud)您可以在此处参考其他信息:http://developer.android.com/reference/android/view/LayoutInflater.html
use*_*760 12
LayoutInflater li = LayoutInflater.from(getApplicationContext());
View cv = li.inflate(R.layout.your_layout, null);
mainlayout.addView(cv);
Run Code Online (Sandbox Code Playgroud)