看来maxWidth对EditText没有影响。有人能对此有所启示吗?
<EditText
android:id="@+id/editTextFoo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autofillHints="port"
android:ems="10"
android:maxWidth="100dp"
tools:targetApi="o" />
如果我将layout_width =“ 100dp”设置如下:
<EditText
android:id="@+id/editTextFoo"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:autofillHints="port"
android:ems="10"
android:maxWidth="100dp"
tools:targetApi="o" />
是的,我刚刚在IDE中进行了检查,这是因为ems="10"
它阻止了视图保持maxWidth 100dp。显然,ems 10需要更大的宽度,因此它覆盖了maxWidth属性。
使用minWidth代替em来防止视图缩小。
或者,您可以使用maxEms
和minEms
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句