我目前在使用SlidingDrawer时遇到麻烦。我希望在应用程序启动时将其关闭,以免造成障碍。但是,尽管将slide.close()放在我的活动的onCreate()中,但仍确定它将打开。如果我改用slide.animateClose(),则似乎已关闭,但这减慢了我的应用程序的下载速度。

如何默认关闭它?

干杯

    <SlidingDrawer
    android:layout_width="fill_parent"
    android:padding="4dp"
    android:id="@+id/Mnu_Slide"
    android:content="@+id/Mnu_SlideCont"
    android:handle="@+id/Mnu_SlideBtn"
    android:layout_gravity="bottom"
    android:layout_height="112dp">
    <ImageView
        android:id="@id/Mnu_SlideBtn"
        android:src="@drawable/handle1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content" />
    <LinearLayout
        android:id="@id/Mnu_SlideCont"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="horizontal"
        android:gravity="center_vertical|center_horizontal" android:background="@drawable/tray1xml">
            <ImageView
                android:id="@+id/Mnu_Chem"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/icon" />
            <ImageView
                android:id="@+id/Mnu_Physics"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/physicon" />
    </LinearLayout>
</SlidingDrawer>

最佳答案

我看不出有任何明显的错误。它看起来与我自己的SlidingDrawer代码(已包含在this question中)非常相似,并且始终开始关闭,而无需在onCreate()方法中显式关闭它。

我怀疑这可能与内部放置的任何视图有关:LinearLayout是否偶然?尝试将其更改为RelativeLayoutdocs for SlidingDrawer有点模糊,但是他们确实说:


  滑动抽屉应用作
  覆盖内部布局。这表示
  滑动抽屉只能使用
  在FrameLayout或
  例如RelativeLayout。


希望能有所帮助。

09-09 23:04
查看更多