Android中TextInputEditText的paddingHorizontal属性不生效问题求助
Android中TextInputEditText的paddingHorizontal属性不生效问题求助
各位大佬好,我最近写布局的时候碰到个小坑,特意来请教下大家:
我给TextInputEditText设置了paddingHorizontal="40dp",结果发现这个属性完全不生效,输入框里的文字还是紧贴着边缘,根本没有预期的左右内边距效果。
先贴下我原本的布局代码:
<com.google.android.material.textfield.TextInputLayout android:id="@+id/name_inputLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="16dp" app:endIconMode="clear_text" app:hintEnabled="false"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/name_editText" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Name" android:inputType="text" android:paddingHorizontal="40dp"/> </com.google.android.material.textfield.TextInputLayout>
目前我用了个临时解决办法:换成分别设置paddingStart="40dp"和paddingEnd="40dp",这样就能达到预期的左右内边距效果了。
有没有大佬知道为啥paddingHorizontal在TextInputEditText这里不生效呀?是这个控件本身的特性,还是我哪里配置错了?麻烦指点下,谢谢啦!




