简体   繁体   中英

Scroll view of center aligned linear layout is wrapping top content in small resolution devices and landscape mode

Scroll view of center aligned linear layout is wrapping top content in small resolution devices as well as landscape mode too.

but when i removed the center_vertical in linear lay out it is working fine, but i want that linear layout to be in center_vertical only.

Below is my code:!

<ScrollView
        android:id="@+id/bodyscrollview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:fillViewport="true" >

        <LinearLayout
            style="@style/app_update_alert_bg"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_gravity="center_vertical"
            android:layout_marginBottom="5dp"
            android:orientation="vertical" >

            <TextView
                style="@style/app_update_alert_bg_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/updateinfo1" />

            <TextView
                style="@style/app_update_alert_bg_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/updateinfo2" />

            <ImageView
                style="@style/margin5dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/switching_image_border"
                android:src="@drawable/switching_image_sb" />

            <ImageView
                style="@style/margin5dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/switching_image_border"
                android:src="@drawable/switching_image_ucc" />

            <CheckBox
                android:id="@+id/chckbox_dontshow_again"
                style="@style/margin5dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:button="@drawable/custom_checkbox"
                android:text="@string/updateinfo_dontshow" />

            <Button
                android:id="@+id/btn_updatealert_confirmation"
                style="@style/buttonStyle.signInButton"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_margin="5dp"
                android:text="OK" />
        </LinearLayout>
    </ScrollView>

Try this way,hope this will help you to solve your problem.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center">

    <ScrollView
        android:id="@+id/bodyscrollview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="5dp">

        <LinearLayout
            style="@style/app_update_alert_bg"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                style="@style/app_update_alert_bg_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/updateinfo1" />

            <TextView
                style="@style/app_update_alert_bg_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/updateinfo2"
                android:layout_marginTop="5dp"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/switching_image_border"
                android:src="@drawable/switching_image_sb"
                android:layout_marginTop="5dp"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/switching_image_border"
                android:src="@drawable/switching_image_ucc"
                android:layout_marginTop="5dp"/>

            <CheckBox
                android:id="@+id/chckbox_dontshow_again"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:button="@drawable/custom_checkbox"
                android:text="@string/updateinfo_dontshow"
                android:layout_marginTop="5dp"/>

            <Button
                android:id="@+id/btn_updatealert_confirmation"
                style="@style/buttonStyle.signInButton"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="5dp"
                android:text="OK" />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM