The solution proposed by ganesh2shiv works for the most part, although I've found it also de-centres the hint text displayed inside the EditText when not focused.
A better trick is to set the desired paddingTop
to the EditText but also embed the extra padding within the EditText's background. A fairly sane way to do this is to wrap your original background in a <layer-list>
and set the <item android:top="...">
attribute to match the paddingTop
of your EditText.
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/floating_hint_margin"
android:background="@drawable/bg_edit_text" />
</android.support.design.widget.TextInputLayout>
And the bg_edit_text.xml
drawable file:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="@dimen/floating_hint_margin">
<your original background; can be <bitmap> or <shape> or whatever./>
</item>
</layer-list>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…