2

There seems to be an ui scrolling issue when we center aligned all UI components using scrollview and taps on edittext which pops-up keyboard then not all ui scrolling up/down properly if added in ScrollVIew. There seems to problem with the current approach as its not allowing us to adjust after using all available layout features. I did searched on internet to fix this but not found a solution.

I did used android:windowSoftInputMode="adjustResize"

If anyone can suggest a solution that would be quite helpful.

Code snippet::

<?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"
    android:background="@color/grey"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/topbar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/topbar"
        android:gravity="center_horizontal" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dip"
            android:gravity="center"
            android:src="@drawable/dash_logo" />
    </LinearLayout>

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:layout_gravity="center" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center" >

            <TextView
                style="@style/iAccetpTitle"
                android:layout_gravity="center"
                android:layout_margin="10dip"
                android:text="@string/welcome" />

            <LinearLayout
                android:id="@+id/eureka_header"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:background="@drawable/rounded_rectangle"
                android:orientation="vertical" >

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingBottom="10dp"
                    android:paddingLeft="15dp"
                    android:paddingTop="10dp" >

                    <TextView
                        android:id="@+id/enter_text"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:paddingTop="8dp"
                        android:singleLine="false"
                        android:text="@string/enter_number"
                        android:textColor="@color/grey_black"
                        android:textSize="16sp" />

                    <EditText
                        android:id="@+id/phone_number_edittext"
                        android:layout_width="180dip"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:layout_margin="5dp"
                        android:background="@drawable/iaccept_mobiletextfield"
                        android:gravity="center"
                        android:inputType="number"
                        android:maxLength="10"
                        android:paddingRight="5dp"
                        android:paddingTop="2dp"
                        android:textColor="#666666"
                        android:textSize="15sp"
                        android:textStyle="bold" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingBottom="10dp"
                    android:paddingLeft="15dp" >

                    <TextView
                        android:id="@+id/enter_email"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:paddingTop="2dp"
                        android:singleLine="false"
                        android:text="@string/enter_email"
                        android:textColor="@color/grey_black"
                        android:textSize="16sp" />

                    <EditText
                        android:id="@+id/email_edittext"
                        android:layout_width="180dip"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:layout_margin="5dp"
                        android:background="@drawable/iaccept_mobiletextfield"
                        android:hint="@string/email_hint"
                        android:inputType="textEmailAddress"
                        android:maxLength="49"
                        android:paddingLeft="5dp"
                        android:paddingRight="5dp"
                        android:paddingTop="2dp"
                        android:textColor="#666666"
                        android:textSize="14sp"
                        android:textStyle="bold" />
                </LinearLayout>
            </LinearLayout>

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/icon_termscondtion" />

                <Button
                    android:id="@+id/terms_n_cond"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/terms_cond_selector" />
            </LinearLayout>

            <Button
                android:id="@+id/iaccept_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|center_horizontal"
                android:layout_margin="10dip"
                android:background="@drawable/iaccept_selector"
                android:onClick="onClick"
                android:text="@string/i_accept"
                android:textColor="@drawable/white"
                android:textSize="18sp"
                android:textStyle="bold" />
        </LinearLayout>
        <!-- </ScrollView> -->
    </ScrollView>

</LinearLayout>
4

1 回答 1

2

android:layout_gravity="center"从 ScrollView 的内部 LinearLayout 中移除。

它应该工作。

于 2013-05-31T11:54:51.207 回答