【问题标题】:set sliding drawer height dynamically动态设置滑动抽屉高度
【发布时间】:2011-03-18 17:01:27
【问题描述】:

我想动态或静态地定义滑动抽屉高度的高度。 下面是我的 xml 布局文件。任何建议将不胜感激。

<?xml version="1.0" encoding="utf-8"?>

    <SlidingDrawer android:layout_width="fill_parent"
        android:id="@+id/SlidingDrawer" android:handle="@+id/slideHandleButton"
        android:content="@+id/contentLayout" android:layout_height="wrap_content">
        <ImageView android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:id="@+id/slideHandleButton"
            android:background="@drawable/icon_movie"></ImageView>
        <LinearLayout android:layout_width="fill_parent"
            android:id="@+id/contentLayout" android:gravity="center"
            android:background="#C0C0C0" android:layout_height="wrap_content">
            <Gallery android:id="@+id/gallery" android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </SlidingDrawer>
</FrameLayout>

【问题讨论】:

标签: java android android-layout android-ui slidingdrawer


【解决方案1】:

您可以将高度设置为特定高度,例如200dp,或者如果您想使用wrap_content,也可以使用this workaround 之类的东西。

【讨论】:

  • 嘿,马特,我已经尝试将高度设置为 200 dp,但效果不佳,当我将 layout_height 属性设置为 200 dp 时,滑块只会移动到屏幕中心。有什么想法吗?
  • 你的意思是,它不再附在屏幕底部了?可能是您的 FrameLayout 没有将其 layout_height 设置为 fill_parent,而且您可能必须在 SlidingDrawer 上设置 android:layout_gravity="bottom"
【解决方案2】:

只需在 xml 的滑动抽屉中设置为 pmargin

android:layout_marginTop="50dip"

【讨论】:

    【解决方案3】:

    为 SlidingDrawer 使用 topOffset 属性。

    像这样……

    <SlidingDrawer 
    ...
    android:topOffset="800px"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多