jeudi 21 mai 2015

set navigation drawer above view pager dynamically

I just want to put my navigation drawer on the top of my app, right after the navigation drawer my sliding menu should be displayed. So I figured out to do this with "android:layout_marginTop="xdp"/>". When I don't do this my nav drawer and the sliding tabs will overlap each other.

So my question is how can I do this dynamically with xml e.g. how can I get the height of the navdrawer to set the correct size for the marginTop?

Here is my xml-layout:

        <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <com.starpedia.marvin.swc_pedia.FragmentNavigationDrawer
        xmlns:android="http://ift.tt/nIICcg"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            android:orientation="vertical">

            <!-- The ActionBar -->
            <include
                layout="@layout/toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <!-- The main content view -->
            <FrameLayout
                android:id="@+id/flContent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>

        <!-- The navigation drawer -->
        <ListView
            android:id="@+id/lvDrawer"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:paddingTop="24dp"
            android:divider="@android:color/darker_gray"
            android:dividerHeight="0dp"
            android:background="@android:color/background_light" />


        <com.starpedia.marvin.swc_pedia.SlidingTabLayout
            android:id="@+id/sliding_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"/>
    </com.starpedia.marvin.swc_pedia.FragmentNavigationDrawer>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1"
        android:background="@android:color/white"/>



    </LinearLayout>

and a picture of the current screen displayed.

Thanks for your help in advance.

Aucun commentaire:

Enregistrer un commentaire