您好我正在开发一个应用程序,我想删除工具栏阴影,我尝试将app:elevation="0dp"
添加到AppBarLayout但是在添加此菜单按钮后打开navigationView不起作用,不知道吗?
public class MainActivity extends AppCompatActivity {
private Toolbar toolbar;
private SlidingMenuLayout slidingMenuLayout;
private NavigationView navigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
slidingMenuLayout = (SlidingMenuLayout) this.getLayoutInflater().inflate(
R.layout.activity_main, null);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(slidingMenuLayout);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbar.setLogo(R.drawable.notifications);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.dashboard_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.open_drawer:
toggleMenu();
default:
return super.onOptionsItemSelected(item);
}
}
private void toggleMenu() {
slidingMenuLayout.toggleMenu();
} }
activity_main.xml中:
<net.aparteman.apartemanapp.viewHolder.SlidingMenuLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="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.support.design.widget.NavigationView
android:id="@+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@color/dark_purple"
android:layoutDirection="rtl"
android:textDirection="rtl"
app:elevation="0dp"
app:headerLayout="@layout/dashboard_nav_header"
app:itemTextColor="@color/white"
app:menu="@menu/dashboard_drawer_view"
app:theme="@style/ApartemanStyle" />
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:context=".activity.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:popupTheme="@style/AppTheme" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/dashboard_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:1)
由于提升也会影响View
的z-index,我猜您的FrameLayout
高于Toolbar
正在发生的事情。事件
尝试将FrameLayout
放在XML中的AppBarLayout
之前,或者定义带有上边距的FrameLayout
,以便为Toolbar
留出空间。