2016-06-16 4 views
-1

У меня есть два навигационных меню в макете выдвижного ящика, Слева и Право. Я хочу, чтобы в левом навигационном меню ниже панели инструментов и меню навигации справа на панель, как показано на рисунке ниже:Левое меню навигации под панелью инструментов и правое меню навигации по панели инструментов

enter image description here

Как этого добиться?

Мой Макет:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/id_home_start" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:scrollbars="vertical"> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    tools:context="com.artifex.mupdfdemo.HomeStart"> 
    <include 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     layout="@layout/toolbar_layout" /> 

</LinearLayout> 


    <android.support.design.widget.NavigationView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="50dp" 
     android:id="@+id/home_menu" 
     android:layout_gravity="start"> 
     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      card_view:cardUseCompatPadding="true"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 
       <ImageView 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:src="@drawable/upld" 
        android:layout_marginLeft="1dp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/my_uploads" 
        android:text="My Uploads" 
        android:textColor="#000000" 
        android:textStyle="bold" 
        android:textSize="20dp" 
        android:paddingTop="10dp" 
        android:paddingBottom="10dp" 
        android:gravity="center" 
        /> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 

    </android.support.design.widget.NavigationView> 


    <android.support.design.widget.NavigationView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/profile_menu" 
     android:layout_gravity="end"> 
     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      card_view:cardUseCompatPadding="true"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 
       <ImageView 
        android:layout_width="30dp" 
        android:layout_height="30dp" 
        android:src="@drawable/options" 
        android:layout_marginLeft="1dp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/update_profile" 
        android:text="Update Profile" 
        android:textColor="#000000" 
        android:textStyle="bold" 
        android:textSize="20dp" 
        android:paddingTop="10dp" 
        android:paddingBottom="10dp" 
        android:gravity="center" 
        /> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 


    </android.support.design.widget.NavigationView> 
</android.support.v4.widget.DrawerLayout> 

и мой Java Кодекс:

Toolbar toolbar; 
    DrawerLayout drawerLayout; 
    ActionBarDrawerToggle actionBarDrawerToggle; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_home_start); 
     toolbar = (Toolbar) findViewById(R.id.toolbar); 
     toolbar.setTitle("Home"); 
     setSupportActionBar(toolbar); 
     drawerLayout = (DrawerLayout) findViewById(R.id.id_home_start); 
     actionBarDrawerToggle=new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close); 
     drawerLayout.setDrawerListener(actionBarDrawerToggle); 
    } 

    @Override 
    protected void onPostCreate(Bundle savedInstanceState){ 
     super.onPostCreate(savedInstanceState); 
     actionBarDrawerToggle.syncState(); 
    } 
+0

Поместите свой 'Toolbar' в основном содержании' 'DrawerLayout' в ViewGroup', и установить верхнее поле в левом ящике на высоту «Панели инструментов». –

+0

Да. Но он темнеет на панели инструментов, которая нежелательна. Можете ли вы предложить что-то лучше ?. И могу ли я знать, почему вопрос опущен? –

+0

Настройте прозрачный цвет 'DrawerLayout' на прозрачный и управляйте затемнением. –

ответ

0
<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/id_home_start" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical"> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     tools:context="com.artifex.mupdfdemo.HomeStart"> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:background="@color/primary" 
       android:minHeight="?attr/actionBarSize" 
       card_view:layout_scrollFlags="scroll|enterAlways" 
       card_view:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       card_view:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 
     </android.support.design.widget.AppBarLayout> 

    </LinearLayout> 


    <android.support.design.widget.NavigationView 
     android:id="@+id/home_menu" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:layout_marginTop="?attr/actionBarSize"> 

     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      card_view:cardUseCompatPadding="true"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:layout_marginLeft="1dp" 
        android:src="@drawable/btn_theme_bg_effect" /> 

       <TextView 
        android:id="@+id/my_uploads" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center" 
        android:paddingBottom="10dp" 
        android:paddingTop="10dp" 
        android:text="My Uploads" 
        android:textColor="#000000" 
        android:textSize="20dp" 
        android:textStyle="bold" /> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 

    </android.support.design.widget.NavigationView> 


    <android.support.design.widget.NavigationView 
     android:id="@+id/profile_menu" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end"> 

     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      card_view:cardUseCompatPadding="true"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="30dp" 
        android:layout_height="30dp" 
        android:layout_marginLeft="1dp" 
        android:src="@drawable/btn_theme_bg_effect" /> 

       <TextView 
        android:id="@+id/update_profile" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center" 
        android:paddingBottom="10dp" 
        android:paddingTop="10dp" 
        android:text="Update Profile" 
        android:textColor="#000000" 
        android:textSize="20dp" 
        android:textStyle="bold" /> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 


    </android.support.design.widget.NavigationView> 
</android.support.v4.widget.DrawerLayout> 
+0

не имеет значения ... –

Смежные вопросы