2013年10月8日星期二

[Android] DrawerLayout main interface is covered

navigation interface
 This post last edited by the xiaoguohaha on 2013-10-04 16:00:58

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout">

<include layout="@layout/main_layout"/>
<include layout="@layout/module_layout"/>
<include layout="@layout/user_layout"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>


include first is the layout of the main interface , the latter two are the left and right navigation include the layout , but open the run time is always displayed last a navigation layout solving , statckflow seemingly do not have the problem, and English is limited , the official document scanty .
------ Solution ---------------------------------------- ----
left drawer needs to define attributes android: layout_gravity = "start" and android: layout_width <320dp
Similarly right drawer requires android: layout_gravity = "end" and android: layout_width <320dp

Not tested include the case , include the back should not attribute it directly with these two ?

You can try user_layout define android: layout_gravity = "right" and specify a width of less than 320dp ,
module_layout same treatment ("start" pass "left", "end" pass "right")

Why should include? order to reuse ? If the order to reuse , you can try

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.v4.widget.DrawerLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/drawer_layout">
         
        <include layout="@layout/main_layout"/>
        <LinearLayout
            android:id="@+id/left_drawer"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start">
            <include layout="@layout/module_layout"/>
        </LinearLayout>
        <LinearLayout
            android:id="@+id/right_drawer"
            android:layout_width="300dp"
            android:layout_height="match_parent"
            android:layout_gravity="end" >
            <include layout="@layout/user_layout"/>
        </LinearLayout>
    </android.support.v4.widget.DrawerLayout>
</RelativeLayout>


Also: did not see the necessity of the outermost RelativeLayout , you can take a look Lint recommend
------ eference ---------- -----------------------------
seeking unsinkable , seeking answers
------ eference - -------------------------------------
you do not include the entire layout before it is normal do
------ eference ------------------------------------ ---

not normal , has been covered

------ eference ------------------------------------ ---


3q, resolved , relativelayout is the online reference source, examples

没有评论:

发表评论