简体   繁体   English

右抽屉布局超出页边距

[英]Right Drawer Layout out of margin

I'm using DrawerLayout in my app. 我在我的应用程序中使用DrawerLayout。 I test it in Samsung note 3 and samsung S4 everything is fine. 我在三星note 3和三星S4中进行了测试,一切都很好。 But when it test to Samsung S3 the layout has messed up. 但是,当它对三星S3进行测试时,布局混乱了。 Please refer to below image 请参考下图

Test in Samsung Note 3 and Samsung S4 : http://www.imagesup.net/?di=1514046988962 在Samsung Note 3和Samsung S4中进行测试: http : //www.imagesup.net/? di= 1514046988962

Test in Samsung S3 : http://www.imagesup.net/?di=14140469921515 在Samsung S3中测试: http : //www.imagesup.net/? di= 14140469921515

My xml layout code as following below : 我的xml布局代码如下:

 <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" . 有一次我遇到一个问题,我的代码上的所有内容都不对,但是在运行API 18+的设备上, android:gravity="center_vertical"简单的代码无法正常工作,但我修复了它,只是更改了android:target="18"android:target="16" I choose "16" because it was the version of my Android that was running without any problems. 我选择“ 16”是因为它运行的是我的Android版本,没有任何问题。

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) 我不知道这是否是您的情况,但是请更改Android Manifest.xml中的android target属性,只需尝试一下(y)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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