Android:有没有办法正确地将 SlidingDrawer 宽度和高度设置为半屏?
我必须在右侧设置一个 SlidingDrawer,并且单击时它不应扩展到半个屏幕。我看到了很多教程,我设法或多或少正确地设置了它,但它目前将布局中的所有内容都推到了左边。这是我的 xml:
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/edition_content_linear" android:layout_width="fill_parent"
android:layout_weight="1" android:background="@android:color/white">
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/static_menu_layout" android:layout_height="fill_parent"
android:layout_weight="2" android:visibility="gone" android:background="@drawable/ipad_category_back">
<ExpandableListView android:id="@+id/static_expandable_list"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:drawSelectorOnTop="false" android:groupIndicator="@drawable/expandablelist_selector" android:indicatorLeft="210dp" android:indicatorRight="230dp"></ExpandableListView>
</LinearLayout>
<LinearLayout android:id="@+id/center_linear"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="1">
<ImageView android:scaleType="centerInside"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:id="@+id/cover_image_big"></ImageView>
<WebView android:id="@+id/story_webview"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:visibility="gone"></WebView>
</LinearLayout>
<SlidingDrawer android:id="@+id/slider_drawer"
android:layout_width="250dp" android:layout_height="500dp"
android:orientation="horizontal" android:layout_gravity="center_vertical"
android:handle="@+id/slider_handle" android:content="@+id/slider_expandable_list_container">
<ImageView android:id="@+id/slider_handle"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/menu_handler" />
<RelativeLayout android:id="@+id/slider_expandable_list_container"
android:layout_height="500dp" android:layout_width="250dp">
<ExpandableListView android:id="@+id/slider_expandable_list"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:drawSelectorOnTop="false" android:indicatorLeft="210dp" android:layout_gravity="center_vertical"
android:indicatorRight="230dp" android:groupIndicator="@drawable/expandablelist_selector"></ExpandableListView>
</RelativeLayout>
</SlidingDrawer>
</LinearLayout>
I have to set a SlidingDrawer on the right side and on click it should not expand over the half screen. I saw many tutos and i managed to set it more or less correctly but it's currently pushing everything in the layout to the left. Here is my xml:
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/edition_content_linear" android:layout_width="fill_parent"
android:layout_weight="1" android:background="@android:color/white">
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/static_menu_layout" android:layout_height="fill_parent"
android:layout_weight="2" android:visibility="gone" android:background="@drawable/ipad_category_back">
<ExpandableListView android:id="@+id/static_expandable_list"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:drawSelectorOnTop="false" android:groupIndicator="@drawable/expandablelist_selector" android:indicatorLeft="210dp" android:indicatorRight="230dp"></ExpandableListView>
</LinearLayout>
<LinearLayout android:id="@+id/center_linear"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="1">
<ImageView android:scaleType="centerInside"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:id="@+id/cover_image_big"></ImageView>
<WebView android:id="@+id/story_webview"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:visibility="gone"></WebView>
</LinearLayout>
<SlidingDrawer android:id="@+id/slider_drawer"
android:layout_width="250dp" android:layout_height="500dp"
android:orientation="horizontal" android:layout_gravity="center_vertical"
android:handle="@+id/slider_handle" android:content="@+id/slider_expandable_list_container">
<ImageView android:id="@+id/slider_handle"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/menu_handler" />
<RelativeLayout android:id="@+id/slider_expandable_list_container"
android:layout_height="500dp" android:layout_width="250dp">
<ExpandableListView android:id="@+id/slider_expandable_list"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:drawSelectorOnTop="false" android:indicatorLeft="210dp" android:layout_gravity="center_vertical"
android:indicatorRight="230dp" android:groupIndicator="@drawable/expandablelist_selector"></ExpandableListView>
</RelativeLayout>
</SlidingDrawer>
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将滑动抽屉放在框架布局中总是更好。因为在 Framelayout 中,视图将一个接一个地绘制。即使你的抽屉打开,它也会重叠在下面的视图上。但请注意,在框架布局中,抽屉会扩展到所有框架布局长度。如果你想限制抽屉的展开长度,那么给你的父框架布局一个长度。
Its always better to put the sliding drawer in a frame layout. Because in Framelayout, views will be drawn one on the other. Then even even you drawer opens up it 'll be overlapped on the views beneath. But note that in Framelayout drawer expands up to all the framelayout length. If you want to limit the length of expansion of the drawer, then give a length to your parent framelayout.