简体   繁体   中英

Right Drawer Layout out of margin

I'm using DrawerLayout in my app. I test it in Samsung note 3 and samsung S4 everything is fine. But when it test to Samsung S3 the layout has messed up. Please refer to below image

Test in Samsung Note 3 and Samsung S4 : http://www.imagesup.net/?di=1514046988962

Test in Samsung S3 : http://www.imagesup.net/?di=14140469921515

My xml layout code as following below :

 <include
    android:id="@+id/shopping_cart_slider"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    layout="@layout/shopping_cart_redesign"
    android:choiceMode="singleChoice" />

And this is layout that included :

     <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grey_register_text" >

    <LinearLayout
        android:id="@+id/shopping_cart_redesign_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/grey_register_text"
        android:orientation="vertical" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <RelativeLayout
                android:id="@+id/info_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/white"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/logo_image"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_gravity="center"
                    android:contentDescription="@string/desc_list_item_icon" />

                <com.zukami.apps.dev.blynk.util.CustomListView
                    android:id="@+id/list_shopping_cart"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/logo_image"
                    android:background="@android:color/white"
                    android:divider="@color/grey_register_text"
                    android:dividerHeight="1dp" >
                </com.zukami.apps.dev.blynk.util.CustomListView>

                <View
                    android:id="@+id/border"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_below="@+id/list_shopping_cart"
                    android:layout_marginTop="5dp"
                    android:background="@color/grey_register_text" />

                <RelativeLayout
                    android:id="@+id/total_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/border"
                    android:layout_marginTop="10dp" >

                    <LinearLayout
                        android:id="@+id/total_text_container"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_marginLeft="2dp"
                        android:orientation="vertical" >

                        <TextView
                            android:id="@+id/total_text"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:paddingLeft="10dp"
                            android:text="@string/total"
                            android:textSize="18sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/merchandise_total"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:paddingLeft="10dp"
                            android:text="@string/merchandise_total"
                            android:textSize="15sp" />

                        <TextView
                            android:id="@+id/loyalty"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:paddingLeft="10dp"
                            android:text="@string/loyalty"
                            android:textSize="15sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_marginRight="10dp"
                        android:orientation="vertical" >

                        <TextView
                            android:id="@+id/total_number"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:paddingLeft="5dp"
                            android:textSize="18sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/total_points"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:paddingLeft="5dp"
                            android:textSize="15sp" />
                    </LinearLayout>
                </RelativeLayout>

                <View
                    android:id="@+id/border_two"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_below="@+id/total_layout"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="5dp"
                    android:background="@android:color/black" />

                <Button
                    android:id="@+id/confirm_button"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/border_two"
                    android:layout_marginBottom="2dp"
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/grey_shopping_cart_button"
                    android:gravity="center|center_horizontal"
                    android:text="@string/confirm_order"
                    android:textColor="@android:color/white"
                    android:textSize="16sp"
                    android:textStyle="bold" />

                <View
                    android:id="@+id/space"
                    android:layout_width="match_parent"
                    android:layout_height="2dp"
                    android:layout_below="@+id/confirm_button"
                    android:layout_marginTop="5dp" />
            </RelativeLayout>

            <ImageView
                android:id="@+id/receipt_border"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/info_container"
                android:layout_marginTop="-6dp"
                android:contentDescription="@string/icon"
                android:src="@drawable/receipt_border" />

            <TextView
                android:id="@+id/receipt_footer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/receipt_border"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:textColor="@android:color/white"
                android:textSize="15sp" />

            <ProgressBar
                android:id="@+id/progressBar1"
                style="?android:attr/progressBarStyleLargeInverse"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center"
                android:visibility="gone" />
        </RelativeLayout>
    </LinearLayout>

</ScrollView>

Kindly advise what's wrong with this layout because I have set all width to match parent but still not working in all device. Really appreciate for any kind help.

Hmm, I cant see anything wrong right now.

One time I had a problem that anything on my code was wrong, but on devices running API 18+ the android:gravity="center_vertical" simple did not work, but I fix it just changing the value of android:target="18" to android:target="16" . I choose "16" because it was the version of my Android that was running without any problems.

I don't know if this is your case, but change the android target property at Android Manifest.xml, just give it a try (y)

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