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几乎没有任何变化).此实现支持垂直和水平方向.

试试看!

问候,
雅各

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...