tôi nhận thấy một số hành vi kỳ lạ của TextInputLayout:TextInputLayout không hiển thị khi Chế độ xem thêm lập trình
Khi tôi thêm dòng sau vào cách bố trí của tôi:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/txtFirstName"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="In layout"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
mọi thứ hoạt động như mong đợi.
Khi tôi thổi phồng một Layout tương tự như:
View v = LayoutInflater.from(this).inflate(R.layout.edittext_w_surrounding_textinputlayout, null);
EditText editText = (EditText) v.findViewById(R.id.editText);
editText.setHint("Added programmatically");
ViewGroup root = (ViewGroup) findViewById(R.id.root);
root.addView(v);
các TextInputLayout
không xuất hiện và EditText
cư xử theo tiêu chuẩn.
Bất kỳ ý tưởng nào về lý do có thể là gì?
bố trí cho thư mục gốc ở đâu? – matty357
Đó là trong bố cục của Hoạt động. Đó là LinearLayout chính xác. – FWeigl