У меня есть два навигационных меню в макете выдвижного ящика, Слева и Право. Я хочу, чтобы в левом навигационном меню ниже панели инструментов и меню навигации справа на панель, как показано на рисунке ниже:Левое меню навигации под панелью инструментов и правое меню навигации по панели инструментов
Как этого добиться?
Мой Макет:
<?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();
}
Поместите свой 'Toolbar' в основном содержании' 'DrawerLayout' в ViewGroup', и установить верхнее поле в левом ящике на высоту «Панели инструментов». –
Да. Но он темнеет на панели инструментов, которая нежелательна. Можете ли вы предложить что-то лучше ?. И могу ли я знать, почему вопрос опущен? –
Настройте прозрачный цвет 'DrawerLayout' на прозрачный и управляйте затемнением. –