我想添加投影效果到滑动菜单(Jeremyfeinstein),它从页面的右侧打开。这就是它所发生的事情

但它应该类似于下面的内容

我已经浏览了滑动菜单源码,并复制了以下内容:
//in my activity
SlidingMenu sm = getSlidingMenu();
sm.setMode(SlidingMenu.RIGHT);
//set the width to 10 and my padding to 10 in listview as well
sm.setShadowWidth(10);
//similar shadow effect inside original example
sm.setShadowDrawable(R.drawable.shadow);
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:endColor="#33000000"
android:centerColor="#11000000"
android:startColor="#00000000" />
</shape>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#000000"
android:dividerHeight="1dip"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>但是我得到了错误的阴影效果,我如何解决这个问题?
发布于 2014-03-14 16:41:48
我还没有找到如何处理组件的参数。
这是我的解决方案: Java
SlidingMenu sm = getSlidingMenu();
sm.setMenu(R.layout.sliding_menu_xml);
sm.setMode(SlidingMenu.RIGHT);和其他你想要的配置
sliding_menu_xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarStyle="outsideOverlay" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="10dp" >
...
</LinearLayout>
</ScrollView>
<View
android:id="@+id/view1"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:background="@drawable/background_shadow" />
</RelativeLayout>background_shadow.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:centerColor="#22000000"
android:endColor="#00000000"
android:startColor="#44000000" />
</shape>使用#00,#22和#44来获得颜色的效果。
发布于 2015-10-05 17:46:37
我有一个更简单的方法。
SLIDING_CONTENT将滑动(不包括操作栏)
SLIDING_WINDOW将滑动窗口(包括操作栏)
在attach of sliding菜单上尝试以下代码行
slidingMenu.attachToActivity(this,SlidingMenu.SLIDING_CONTENT);
https://stackoverflow.com/questions/21076281
复制相似问题