【发布时间】:2015-02-19 20:39:36
【问题描述】:
我正在使用最新版本 (3.0) 的 SlidingUpPanelLayout 库。如果它在后台运行,Android 操作系统会定期杀死我的 Activity(按 Home 而不是 Back 退出)。如果发生这种情况,并且面板在用户上次使用应用程序时展开,那么面板在创建时仍会展开,但里面的所有内容都会消失。基本上是一个空白屏幕。
在这种情况下,我实际上想将活动重置为其初始状态(完全退出后打开),该状态已折叠。但我无法让它发挥作用。在布局 xml 中,我将初始状态设置为折叠。
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="48dp"
sothree:umanoShadowHeight="4dp"
sothree:umanoInitialState="collapsed" >
我也放了这条线
slidingUpPanelLayout.setPanelState(PanelState.COLLAPSED);
在 onCreate() 的一些地方,但面板没有折叠。我在每次折叠尝试之前和之后打印了面板状态,发现即使在第一次折叠尝试之前,panelState 实际上也设置为折叠状态,即使它显然没有折叠。
这是库中的错误,还是我做错了什么。
感谢您的帮助。
【问题讨论】:
标签: android android-layout android-activity