首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在RTL模式的slidingmenu中添加适当的投影

如何在RTL模式的slidingmenu中添加适当的投影
EN

Stack Overflow用户
提问于 2014-01-12 23:12:25
回答 2查看 1.4K关注 0票数 0

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

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

我已经浏览了滑动菜单源码,并复制了以下内容:

代码语言:javascript
复制
//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"

        />

但是我得到了错误的阴影效果,我如何解决这个问题?

EN

回答 2

Stack Overflow用户

发布于 2014-03-14 16:41:48

我还没有找到如何处理组件的参数。

这是我的解决方案: Java

代码语言:javascript
复制
SlidingMenu sm = getSlidingMenu();
sm.setMenu(R.layout.sliding_menu_xml);
sm.setMode(SlidingMenu.RIGHT);

和其他你想要的配置

sliding_menu_xml:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
<?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来获得颜色的效果。

票数 1
EN

Stack Overflow用户

发布于 2015-10-05 17:46:37

我有一个更简单的方法。

SLIDING_CONTENT将滑动(不包括操作栏)

SLIDING_WINDOW将滑动窗口(包括操作栏)

在attach of sliding菜单上尝试以下代码行

slidingMenu.attachToActivity(this,SlidingMenu.SLIDING_CONTENT);

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21076281

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档