我已在MarshMallow
設備上進行測試。當我爲EditText
寫入xml並將PaddingBottom
設置爲Retype EditText
。但它不工作。但是當我設置PaddingLeft
到New PassWord
EditText
工作正常。EditText填充不按預期在Android中工作
計算策略:1
XML代碼:
<EditText
android:id="@+id/change_password_old_password_edittext"
android:layout_below="@+id/change_password_mobileNumber_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Old Password"
android:layout_marginTop="20.0dip"
android:textColorHint="#40000000"
android:textSize="@dimen/textsize16"/>
<EditText
android:id="@+id/change_password_new_password_edittext"
android:layout_below="@+id/change_password_old_password_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="New Password"
android:layout_marginTop="20.0dip"
android:textColorHint="#40000000"
android:paddingLeft="10dip"
android:textSize="@dimen/textsize16"/>
<EditText
android:id="@+id/change_password_retype_password_edittext"
android:layout_below="@+id/change_password_new_password_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Retype Password"
android:layout_marginTop="20.0dip"
android:paddingBottom="10dip"
android:textColorHint="#40000000"
android:textSize="@dimen/textsize16"/>
截圖:
計算策略:2
然後我決定以編程方式設置PaddingBottom
。但它給怪異的輸出。
Java代碼:
內部OnCreate
方法
EditText change_password_retype_password_edittext = (EditText)findViewById(R.id.change_password_retype_password_edittext);
change_password_retype_password_edittext.setPadding(0,0,0,10);
輸出:
備註:我已在
Marshmallow
,LolliPop
和Jellybean
上進行過測試。但在所有設備不工作。
這似乎與佈局沒有問題。發佈整個佈局代碼。 –
@AkshayBhat你看到屏幕截圖的問題是顯示.. – Ironman
是的,但我複製你的佈局代碼,並嘗試,它工作正常 –