Android 按钮动态放置在按钮上
我想知道是否有办法在屏幕底部放置一个按钮,无论设备的屏幕尺寸如何。我基本上希望按钮有一个重力=“底部”,而不仅仅是它的文本。我一直在尝试这样做,但找不到方法。有什么建议吗?
I wanted to know if there is a way to place a button on the bottom of the screen, no matter what size screen the device has. I basically want the button to have a gravity="bottom", not just its text. I have been trying to do this, and I cannot find a way to do it. any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
按钮采用什么布局?使用相对布局,您可以将按钮设置为 align_parent_bottom。
What layout is the button in? Using a relative layout, you can set the button to align_parent_bottom.
使用带有
layout_height="fill_parent"
的RelativeLayout
,然后在 XML 文件中将按钮的layout_alignParentBottom
值设置为true
use a
RelativeLayout
withlayout_height="fill_parent"
then set the button'slayout_alignParentBottom
value totrue
in the XML file没关系,我只是创建了一个子 LinearLayout,然后将
其放入其中,它就起作用了:-)
Never mind, I created a child LinearLayout only for and I put
in the child and it worked :-)
尝试在按钮上使用 android:layout_gravity="bottom" :)
Try using android:layout_gravity="bottom" on the Button :)