我加入一个的LinearLayout视图中显示,这种方式:动态添加TextInputLayout不LinearLayout中
LinearLayout ll=(LinearLayout)findViewById(R.id.linearlayout);
TextInputLayout til=new TextInputLayout(MainActivity.this);
til.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
Log.i("TAG","BEFORE: "+ll.getChildCount());
ll.addView(til);
Log.i("TAG","AFTER: "+ll.getChildCount());
这样,没有显示直到对象,但补充说,因为在第二日志我看到这个数字增加了一个,我刚刚添加的观点。
为什么我看不见?如何在布局中显示新视图?
谢谢。
我认为它不会显示,因为你的'TextInputLayout'是空的。尝试在'TextInputLayout'中添加'TextInputEditText'。 – pike
尝试膨胀它:http://stackoverflow.com/questions/31294230/textinputlayout-not-showing-when-view-added-programmatically – codemirel