我刚刚在我的Android应用程序中实现了jfeinstein10的SlidingMenu库,到目前为止它已经相当不错了。但是,我无法解决的一个问题是让阴影(即setShadowDrawable()
)功能起作用。无论我做什么,影子似乎都是:
以下是我用来构建SlidingMenu的代码(请注意setShadowWidthRes()
和setShadowDrawable()
调用):
SlidingMenu navDrawer = new SlidingMenu(this);
navDrawer.setMode(SlidingMenu.LEFT);
navDrawer.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
navDrawer.setShadowWidthRes(R.dimen.shadow_width); // this is 25dp
navDrawer.setShadowDrawable(R.drawable.drawer_shadow);
navDrawer.setBehindOffsetRes(R.dimen.slidingmenu_offset);
navDrawer.setFadeDegree(0.35f);
navDrawer.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
navDrawer.setMenu(R.layout.navdrawer_layout);
...这里是drawer_shadow drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FF000000"
android:endColor="#00000000"/>
</shape>
......这是行动中问题的图像: