0
幫助!我有一組edittext字段在(LinearLayout),我啓用和禁用編程。 當我啓用和禁用字段screenshot時,edittexts寬度沒有問題。問題就來了edittexts啓用後,要麼android所有的edittext寬度在方向變化和焦點上的變化
這裏是我的editexts的一個代碼。其餘都是一樣的,只有id是不同的。
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/purchase_price"
android:imeOptions="flagNoExtractUi|actionNext"
android:maxLines="1"
android:singleLine="true"
android:inputType="numberDecimal">
這裏是啓用字段的代碼。
public void onCreate(Bundle savedInstanceState) {
enabledEdittext = mPurchasePrice.getBackground();
disabledEditext = ContextCompat.getDrawable(this, R.drawable.disabled_edittext);
.
.
.
mPurchasePrice.setBackground(enabledEdittext);
}
我改變了背景,因爲客戶的要求是當禁用字段時刪除edittext下的行。 – vyxf