Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextInputLayout inside the scrollview

I am using TextInputLayout inside the scrollview , when i come to the app then the view is visible fine but when i start scrollview then the view start scrollview but original view is also shown below it. I am attaching the snapshot please let me know the problem.

when i come to the app it looks like this :

when i come to the app

and when i start scrolling it looks like this :

when i start scrolling

Here is my code:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background = "@android:color/transparent"

    >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/attch_photo_ll"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_margin="5dp"
        android:background="#CBCFD3"
        >
        <Button
            android:id="@+id/attach_photo_btn"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@null"
            android:textStyle="bold"
            android:textSize="@dimen/_13sdp"
            android:inputType="textNoSuggestions"
            android:paddingLeft="10dp"
            android:textColor="@android:color/white"
            android:text="Attach Photo"
            />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/photo_ll"
        android:visibility="gone"
        android:layout_width="@dimen/image_width"
        android:layout_height="@dimen/image_height"
        android:layout_margin="5dp"
        android:layout_gravity="center"
        android:gravity="center">
        <ImageView
            android:id="@+id/photo_img"
            android:adjustViewBounds="true"
            android:layout_width="@dimen/image_width"
            android:layout_height="@dimen/image_height"
            android:scaleType="fitXY"/>
    </LinearLayout>

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

        <EditText
            android:id="@+id/firstName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="First Name" />

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


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

        <EditText
            android:id="@+id/lastName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Last Name" />

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



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

        <EditText
            android:id="@+id/mobile_one"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Mobile 1" />

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



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

        <EditText
            android:id="@+id/mobile_two"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Mobile 2 (Optional)" />

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



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

        <EditText
            android:id="@+id/email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Email" />

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="@dimen/_8sdp"
        android:orientation="horizontal"
        android:weightSum="3">

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

            <EditText
                android:id="@+id/aadhar_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Aadhar No." />

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


        <android.support.design.widget.TextInputLayout
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:id="@+id/aadhar_card1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

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

        <android.support.design.widget.TextInputLayout
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:id="@+id/aadhar_card2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

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


    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="@dimen/_8sdp"
        android:layout_marginBottom="@dimen/_8sdp"
        android:orientation="horizontal"
        android:weightSum="3">

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

            <EditText
                android:id="@+id/pancard"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Pan Card No."/>

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

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

            <EditText
                android:id="@+id/pancard1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

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

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

            <EditText
                android:id="@+id/pancard2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

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


    </LinearLayout>
</LinearLayout>
</ScrollView>
like image 398
Amit Ranjan Avatar asked May 25 '26 10:05

Amit Ranjan


1 Answers

Try this.
Remove the hint from the EditText and add the hint to TextInputLayout in your layout
For e.g

   <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_username"
        android:layout_width="match_parent"
        android:hint="First Name"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/firstName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </android.support.design.widget.TextInputLayout>
like image 120
Deepak Goyal Avatar answered May 27 '26 02:05

Deepak Goyal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!