本文介绍了Android 移除导航抽屉上的阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我正在使用库存的导航抽屉 v4,我问如何在导航抽屉打开时删除该背景阴影.
Hi, I'm using stock Navigation drawer v4 and i ask how can delete that background shadow when navigation drawer is open.
这是我的 NavigationDrawerFragment.java 代码
this is my code of NavigationDrawerFragment.java
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
mFragmentContainerView = getActivity().findViewById(fragmentId);
mDrawerLayout = drawerLayout;
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.trasparent, GravityCompat.START);
// set up the drawer's list view with items and click listener
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
这是 MainActivity.xml
And this is MainActivity.xml
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Main layout -->
<FrameLayout
android:id="@+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/ImageView3_Left"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<!-- The navigation drawer -->
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:background="#FFFFFFFF"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"/>
</android.support.v4.widget.DrawerLayout>
推荐答案
我找到了解决方案 :D
I find the solution :D
mDrawerLayout.setScrimColor(getResources().getColor(android.R.color.transparent));
在 MainActivity.java 中添加这个
Adding this in MainActivity.java
这篇关于Android 移除导航抽屉上的阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!