Dinash
Dinash

Reputation: 3047

Android two edittext should be shown above the keyboard

This question may look to be very simple but i don't know the answer. In a Login page i have two edittext and when the first edittext is focused the keyboard comes and hides the second edittext and that's the problem for me. All i need is that when the keyboard comes it should not hide the second edittext instead it should show both of them. Waiting for the valuable comments and responses.

Edit: #1

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <RelativeLayout android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="@drawable/login_bg">
    <!-- <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" 
        android:id="@+id/loginScrollView" android:layout_above="@+id/footer" android:scrollbars="vertical" 
        android:fadingEdge="none"> -->
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:id="@+id/loginMainLayout" android:layout_above="@+id/footer">

        <ImageView android:layout_width="fill_parent" android:id="@+id/logo_image_login"
            android:layout_height="0dip" android:layout_weight="27"
            android:src="@drawable/video_date_logo_a" android:scaleType="fitCenter"
            android:layout_marginTop="20dip" android:layout_marginBottom="0dip"></ImageView>

        <TableLayout android:layout_width="fill_parent"
            android:layout_height="0dip" android:layout_weight="23"
            android:paddingLeft="5dip" android:paddingRight="5dip">
            <TableRow android:layout_marginLeft="10dip"
                android:layout_height="0dip" android:layout_weight="1"
                android:layout_marginRight="5dip" android:layout_marginTop="10dip"
                android:layout_marginBottom="5dip" android:gravity="center_vertical">
                <TextView android:layout_width="0dip"
                    style="@style/ivideodate.blue.small" android:layout_weight="0.35"
                    android:layout_height="wrap_content" android:text="@string/login_email"></TextView>
                <EditText android:layout_width="0dip" android:id="@+id/login_emailid"
                    android:layout_weight="0.80" android:layout_height="wrap_content"
                    android:maxLength="40" android:singleLine="true" android:text=""
                    style="@style/ivideodate.black.input" android:background="@drawable/tagline_bg_a"
                    android:focusableInTouchMode="true" android:layout_marginRight="5dip"
                    android:inputType="textEmailAddress"></EditText>
            </TableRow>
            <TableRow android:layout_marginLeft="10dip"
                android:layout_marginRight="5dip" android:layout_marginTop="10dip"
                android:layout_marginBottom="5dip" android:layout_height="0dip"
                android:layout_weight="1" android:gravity="center_vertical">
                <TextView android:layout_width="0dip"
                    style="@style/ivideodate.blue.small" android:layout_weight="0.35"
                    android:layout_height="wrap_content" android:text="@string/login_password"></TextView>
                <EditText android:layout_width="0dip" android:id="@+id/login_password"
                    android:maxLength="40" android:singleLine="true"
                    android:layout_weight="0.80" android:layout_height="wrap_content"
                    android:text="" style="@style/ivideodate.black.input"
                    android:background="@drawable/tagline_bg_a" android:password="true"
                    android:layout_marginRight="5dip"></EditText>
            </TableRow>
            <TableRow android:layout_marginLeft="10dip"
                android:layout_marginRight="5dip" android:layout_marginTop="5dip"
                android:layout_marginBottom="3dip" android:layout_height="0dip"
                android:layout_weight="1.3" android:gravity="center_vertical">
                <TextView android:layout_width="0dip"
                    android:layout_weight="0.35" android:layout_height="wrap_content"></TextView>
                <LinearLayout android:layout_width="0dip"
                    android:layout_weight="0.80" android:layout_height="wrap_content">
                    <Button android:layout_width="wrap_content" android:id="@+id/login_submit"
                        android:layout_height="wrap_content" android:background="@drawable/login_blue_bt"></Button>
                </LinearLayout>
            </TableRow>


            <TableRow android:layout_marginLeft="10dip"
                android:layout_marginRight="5dip" android:layout_marginTop="5dip"
                android:layout_marginBottom="2dip" android:layout_height="0dip"
                android:layout_weight="1" android:gravity="center_vertical">
                <TextView android:layout_width="0dip"
                    android:layout_weight="0.35" android:layout_height="wrap_content"></TextView>
                <LinearLayout android:layout_width="0dip"
                    android:gravity="center" android:layout_weight="0.80"
                    android:layout_height="wrap_content">
                    <CheckBox android:layout_width="fill_parent" android:id="@+id/check_stayloggedin"
                        android:layout_height="wrap_content" android:button="@drawable/check_box_event"
                        android:gravity="center_vertical" android:text="Stay Logged In"
                        style="@style/ivideodate.blue.small" android:paddingLeft="35dip"></CheckBox>
                    <!-- android:button="@drawable/check_box_event" -->
                    <!-- <TextView android:layout_width="wrap_content" android:textStyle="bold" 
                        android:layout_marginLeft="5dip" android:layout_height="wrap_content" android:text="Stay 
                        Logged In"></TextView> -->
                </LinearLayout>
            </TableRow>
            <TableRow android:layout_marginLeft="10dip"
                android:layout_marginRight="5dip" android:layout_marginTop="3dip"
                android:layout_marginBottom="10dip" android:layout_height="wrap_content"
                android:gravity="center_vertical">
                <TextView android:layout_width="0dip"
                    android:layout_weight="0.35" android:layout_height="wrap_content"></TextView>
                <LinearLayout android:layout_width="0dip"
                    android:layout_weight="0.80" android:layout_height="wrap_content">
                    <!-- <Button android:layout_width="wrap_content" android:id="@+id/forgot_password" 
                        style="@style/ivideodate.blue.small" android:background="@android:color/transparent" 
                        android:layout_height="wrap_content" android:text="@string/login_forgotpassword"></Button> -->
                    <ImageView android:layout_width="wrap_content"
                        android:id="@+id/forgot_password" android:src="@drawable/forgot"
                        style="@style/ivideodate.blue.small" android:background="@android:color/transparent"
                        android:layout_height="wrap_content" android:text="@string/login_forgotpassword"></ImageView>

                </LinearLayout>
            </TableRow>
        </TableLayout>

    </LinearLayout>
    <!-- </ScrollView> -->
    <LinearLayout android:layout_width="fill_parent"
        android:id="@+id/footer" android:layout_alignParentBottom="true"
        android:layout_height="wrap_content" android:background="@drawable/bottom_strip"
        android:padding="0dip">
        <!-- <ImageView android:layout_width="0dip" android:layout_weight="1" 
            android:layout_height="wrap_content" android:src="@drawable/not_member_txt" 
            android:layout_margin="10dip"></ImageView> -->
        <!--<TextView android:textSize="18sp" android:textStyle="bold" android:layout_weight="1" 
            android:layout_height="fill_parent" android:textColor="#FFFFFF" android:text="Not 
            a Member?" android:gravity="center" android:layout_width="0dip"></TextView> -->
        <!-- <ImageView android:layout_width="0dip" android:layout_weight="1" 
            android:layout_height="wrap_content" android:src="@drawable/sign_up_txt" 
            android:layout_marginLeft="25dip" android:layout_marginTop="10dip" android:id="@+id/signup_button"></ImageView> -->

        <!--<TextView android:layout_width="0dip" android:layout_weight="1" android:gravity="center" 
            android:layout_height="fill_parent" android:textColor="#FFFFFF" android:textSize="18sp" 
            android:text="Sign Up here" android:layout_marginLeft="25dip" android:textStyle="bold" 
            android:id="@+id/signup_button"></TextView> -->

        <TextView android:textSize="18sp" android:textStyle="bold"
            android:layout_height="fill_parent" android:paddingLeft="20dip"
            android:textColor="#FFFFFF" android:text="Not a Member?"
            android:gravity="center" android:layout_width="wrap_content"></TextView>
        <LinearLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:gravity="right|center_vertical">
            <ImageView android:layout_width="wrap_content"
                android:gravity="center" android:layout_height="wrap_content"
                android:textSize="18sp" android:layout_gravity="center_vertical|right"
                android:layout_marginRight="20dip" android:src="@drawable/signup_here"
                android:id="@+id/signup_button"></ImageView>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

Upvotes: 0

Views: 2700

Answers (2)

user370305
user370305

Reputation: 109237

Put this line in your manifest.xml activity's tag

 <activity android:windowSoftInputMode="adjustResize" ..>

EDIT:

Also look at here android:windowSoftInputMode for more options...

EDIT:

<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content">
            <TableLayout ....
...
            </TableLayout>
</ScrollView>

Upvotes: 5

kaspermoerch
kaspermoerch

Reputation: 16570

Try placing the entire layout inside a ScrollView. The ScrollView will then wrap the layout, so that it is placed above the keyboard and you can scroll through it.

If you supply your layout file, I might be able to provide you with a more solid answer.

Upvotes: 0

Related Questions