user8120957
user8120957

Reputation:

Not able to give space between hint and line inside texIinputLayout android

I am trying to give gap between hint and below line inside TextInputLayout ,In design it is showing gap if I include paddingBottom.But after running the app that gap is not reflecting.Below is my code.

    <RelativeLayout
            android:id="@+id/input_password_outer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/layout_country_text_fields"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <EditText
                    android:id="@+id/input_oldpwd_text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Confirm New Password"
                    android:inputType="textPassword"
                    android:paddingBottom="25dp"
                    android:textColor="@color/registration_login_edit_text"
                    android:textSize="15sp" />

            </android.support.design.widget.TextInputLayout>

            <LinearLayout
                android:layout_width="38dp"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginTop="10dp"
                android:layout_weight="@dimen/password_eye_weight"
                android:gravity="right|center_horizontal"
                android:scaleType="fitXY">

                <ToggleButton
                    android:id="@+id/confirm_password_toggle_button"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:layout_alignParentRight="true"
                    android:layout_gravity="right"
                    android:background="@color/mobile_screen_background"
                    android:clickable="true"
                    android:gravity="right|center_horizontal"
                    android:padding="3dp"
                    android:textOff=""
                    android:textOn=""
                    />
            </LinearLayout>
        </RelativeLayout>

Upvotes: 0

Views: 457

Answers (1)

Jay Rathod
Jay Rathod

Reputation: 11245

You need to define specific style for TextInputLayout.

<android.support.design.widget.TextInputLayout
    android:id="@+id/input_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/TextInputLayoutLabel" >

    <EditText
        android:id="@+id/input_oldpwd_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Confirm New Password"
        android:inputType="textPassword"
        android:textColor="@color/registration_login_edit_text"
        android:textSize="15sp" />

</android.support.design.widget.TextInputLayout>

And inside res -> values --> style.xml. This will reflect Runtime.

<style name="TextInputLayoutLabel" parent="Widget.Design.TextInputLayout">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@android:color/black</item>
    <item name="android:textSize">15sp</item>
    <item name="android:paddingBottom">25sp</item>
</style>

EDIT 1

Here you can see the output at Runtime on my pixel emulator.

enter image description here

Upvotes: 1

Related Questions