将 FrameLayout 移至左侧(包含 SlidingDrawer Button 手柄)
我有一个 Button,它是 SlidingDrawer 的手柄。我还有另一个按钮,我希望可以在与 SlidingDrawer 按钮手柄相同的行上访问该按钮。这对于 LinearLayout 或relativelayout 来说似乎是不可能的,但我可以通过 FrameLayout 让它工作。
我的问题是:手柄按钮只会显示在屏幕中央。我希望每个按钮都位于屏幕的两侧(按钮手柄位于右侧,另一个按钮位于左侧)。如何将这个 FrameLayout 包裹的按钮移动到屏幕右侧?一切都包含在RelativeLayout中,但我还无法实现这个按钮移动。
相关的Android XML布局代码(再次,全部包装在RelativeLayout中):
<Button android:id="@+id/EditListActivityButton"
android:text="@string/mappage_edititems"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/addItemSlidingDrawerHandle"
android:layout_above="@+id/item">
</Button>
<SlidingDrawer android:id="@+id/addItemSlidingDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:handle="@+id/addItemSlidingDrawerHandle"
android:content="@+id/addItemSlidingDrawerContent"
android:layout_above="@+id/item"
android:layout_alignParentRight="true">
<FrameLayout android:id="@id/addItemSlidingDrawerHandle"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/goToEditListButton">
<Button android:id="@+id/addItemSlidingDrawerHandleButton"
android:text="@string/mappage_additem"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</FrameLayout>
<LinearLayout android:id="@id/addItemSlidingDrawerContent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#96C120">
<!-- sliding drawer content goes here -->
</LinearLayout>
</SlidingDrawer>
I have a Button which is the handle for a SlidingDrawer. I have another button I want to be accessible on the same row as the SlidingDrawer button handle as well. This does not seem possible with a LinearLayout or a RelativeLayout, but I can get it working via a FrameLayout.
My issue is this: the handle button will only display itself in the center of the screen. I want each button to be on opposite sides of the screen (the button handle to be on the right, and the other button to be on the left). How can I move this FrameLayout-wrapped Button to the right of the screen? Everything is wrapped in a RelativeLayout, but I have not been able to achieve this button move yet.
Relevant Android XML layout code (once again, all wrapped in a RelativeLayout):
<Button android:id="@+id/EditListActivityButton"
android:text="@string/mappage_edititems"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/addItemSlidingDrawerHandle"
android:layout_above="@+id/item">
</Button>
<SlidingDrawer android:id="@+id/addItemSlidingDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:handle="@+id/addItemSlidingDrawerHandle"
android:content="@+id/addItemSlidingDrawerContent"
android:layout_above="@+id/item"
android:layout_alignParentRight="true">
<FrameLayout android:id="@id/addItemSlidingDrawerHandle"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/goToEditListButton">
<Button android:id="@+id/addItemSlidingDrawerHandleButton"
android:text="@string/mappage_additem"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</FrameLayout>
<LinearLayout android:id="@id/addItemSlidingDrawerContent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#96C120">
<!-- sliding drawer content goes here -->
</LinearLayout>
</SlidingDrawer>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能已经晚了,但 mi8 帮助了其他一些人,因为一旦
我没有在手柄按钮周围使用任何布局,
我也非常需要它,我只是添加了
android:padding='<显示尺寸的 3/4>'
在你的 movingDrawer xml
示例中(只需粘贴 xml 并运行):
This may be late, but mi8 help some others since Me too needed it badly once
I didnt use any layout around my handle button
I just added
android:padding='<3/4 th of ur display size>'
in your slidingDrawer xml
Example(just paste in a xml and run):
尝试添加
到slidingDrawer xml中
您还可以看到此链接,
如何让Android SlidingDrawer从左侧滑出?
Try adding
in your slidingDrawer xml
You can also see this link,
How to make an Android SlidingDrawer slide out from the left?