问题
TextInputLayout seems to always have some extra padding at the top (no matter that all margins/paddings are set to 0):
The layout looks like:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/txt_amount"
style="@style/EditTextStyle"
android:hint="@string/hint_amount"
android:inputType="numberDecimal"/>
</android.support.design.widget.TextInputLayout>
How to remove this extra space?
回答1:
You can remove extra space above AppCompatEditText by setting app:hintEnabled="false"
to TextInputLayout but it won't display hint until you re-enable that.
For more info goto Android Developer site -TextInputLayout
Checkout below code
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintEnabled="false">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/txt_amount"
style="@style/EditTextStyle"
android:hint="@string/hint_amount"
android:inputType="numberDecimal"/>
</android.support.design.widget.TextInputLayout>
Hope this helpfull..
@Rajesh
回答2:
You can use this
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@android:color/white">
<com.bugle.customviews.RobotoLightEditText
android:id="@+id/edtName"
style="@style/StyledTilEditText"
android:hint="@string/name"
android:imeOptions="actionNext"
android:inputType="textCapWords" />
</android.support.design.widget.TextInputLayout>
回答3:
Add this line in EditText
android:translationY="-10dp"
来源:https://stackoverflow.com/questions/43541740/removing-textinputlayout-extra-top-padding