微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – SlidingDrawer在开始时半开放

我正在处理我的应用程序,我想知道是否有可能让滑动抽屉部分打开而不是完全关闭,因此用户可以在文本内容达到峰值,然后单击显示更多按钮,这将显示其余部分的文字.

提前致谢.

解决方法:

我遇到了类似的问题,最后我修改了SlidingDrawer,以便在Drawer折叠/关闭时能够显示部分内容.使用SemiClosedSlidingDrawer,您可以使用维度属性“semiClosedContentSize”指定应在折叠/关闭模式下显示内容屏幕数量

<se.smartrefill.view.SemiClosedSlidingDrawer 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res/se.smartrefill.app.x"
    android:id="@+id/mySlidingDrawer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    custom:orientation="horizontal"
    custom:handle="@+id/handle"
    custom:content="@+id/content"
    custom:allowSingleTap="true"
    custom:semiClosedContentSize="40dp"
    >

那么你的attrs.xml(在res / values /中)也需要包含:

<declare-styleable name="SemiClosedSlidingDrawer">
    <attr name="handle" format="integer"/>
    <attr name="content" format="integer"/>
    <attr name="orientation" format="string" />
    <attr name="bottomOffset" format="dimension"  />
    <attr name="topOffset" format="dimension"  />
    <attr name="allowSingleTap" format="boolean" />
    <attr name="animateOnClick" format="boolean" />
    <attr name="semiClosedContentSize" format="dimension" />
</declare-styleable>

,其中’se.smartrefill.app.x’是指AndroidManifest中定义的应用程序包.

此特定SlidingDrawer(上图)配置为使用水平方向,内容视图的40dp宽(和fill_parent高)条带将以折叠/关闭模式显示(向右).在扩展/打开模式下,此实现将像标准SlidingDrawer一样工作,但在折叠/关闭模式下,内容屏幕永远不会被完全隐藏(除非您指定semiClosedContentSize =“0dp”,这将把它变成标准的SlidingDrawer).此实现基于Android-4(“1.6”)中SlidingDrawer的实现,但兼容(包括)Android-14(“4.0”).此实现也应该与Android的未来版本兼容(在API 4和API 14之间的SlidingDrawer几乎没有任何变化).此实现支持垂直和水平方向.

试试看!

问候,
雅各

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐