android drawerlayout 遮罩层白色,DrawerLayout常见问题

2d9141824503?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

图片.png

1.取消DrawerLayout滑出时内容区(Content)域遮罩效果:

如图中Content区域的遮罩半透明效果

源码:

android\support\v4\widget\DrawerLayout.java:

/**

* Set a color to use for the scrim that obscures primary content while a drawer is open.

*

* @param color Color to use in 0xAARRGGBB format.

*/

public void setScrimColor(@ColorInt int color) {

mScrimColor = color;

invalidate();

}

解决办法:

将遮罩层颜色设置为透明即可

mDrawerLayout.setScrimColor(Color.TRANSPARENT);

2.取消DrawerLayout滑出时菜单区(Menu)边缘阴影效果:

如图中Menu区域边缘阴影效果

源码:

android\support\v4\widget\DrawerLayout.java:

/**

* Set a simple drawable used for the left or right shadow. The drawable provided must have a

* nonzero intrinsic width. For API 21 and above, an elevation will be set on the drawer

* instead of using the provided shadow drawable.

*

*

Note that for better support for both left-to-right and right-to-left layout

* directions, a drawable for RTL layout (in additional to the one in LTR layout) can be

* defined with a resource qualifier "ldrtl" for API 17 and above with the gravity

* {@link GravityCompat#START}. Alternatively, for API 23 and above, the drawable can

* auto-mirrored such that the drawable will be mirrored in RTL layout.

*

* @param resId Resource id of a shadow drawable to use at the edge of a drawer

* @param gravity Which drawer the shadow should apply to

*/

public void setDrawerShadow(@DrawableRes int resId, @EdgeGravity int gravity) {

setDrawerShadow(ContextCompat.getDrawable(getContext(), resId), gravity);

}

解决办法:

自定义一个阴影效果

mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值