如何对齐3行按钮,android?

如何对齐3行按钮,android?,第1张

概述我在父级中有线性垂直布局. 然后是底部的水平线性布局,包括3个按钮 我希望活动最左侧的第一个按钮位于底部 中间的第二个按钮 和最右边的第3个按钮 这是xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layou 我在父级中有线性垂直布局.
然后是底部的水平线性布局,包括3个按钮

我希望活动最左侧的第一个按钮位于底部
中间的第二个按钮
和最右边的第3个按钮

这是xml

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:orIEntation="vertical" >   <ImageVIEw    androID:ID="@+ID/vIEwImageVIEw"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_weight="1"    androID:contentDescription="@null"    androID:src="@drawable/ic_launcher" /><linearLayout    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_gravity="bottom" >    <button        androID:ID="@+ID/button1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="button" />    <button        androID:ID="@+ID/button2"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="button" />    <button        androID:ID="@+ID/button3"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:gravity="right"        androID:layout_gravity="fill_vertical"        androID:text="button" /></linearLayout>
解决方法 对于那些类型的对齐(父对象的最左边的一个按钮,中间的另一个按钮以及父布局的最右边的一个按钮)relativeLayout比linearLayout更方便.因为如果你使用relativeLayout作为你的按钮的父布局你可以使用androID:layout_alignParentleft =“true”表示你想要在最左边对齐的一个按钮,androID:layout_centerInParent =“true”在中心和androID中对齐:layout_alignParentRight =“true”以对齐右侧角落的按钮.

试试这个..

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:orIEntation="vertical" >   <ImageVIEw    androID:ID="@+ID/vIEwImageVIEw"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_weight="1"    androID:contentDescription="@null"    androID:src="@drawable/ic_launcher" /><relativeLayout    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_gravity="bottom" >    <button        androID:ID="@+ID/button1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignParentleft="true"        androID:text="button" />    <button        androID:ID="@+ID/button2"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_centerInParent="true"        androID:text="button" />    <button        androID:ID="@+ID/button3"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignParentRight="true"        androID:text="button" /></relativeLayout></linearLayout>
总结

以上是内存溢出为你收集整理的如何对齐3行按钮,android?全部内容,希望文章能够帮你解决如何对齐3行按钮,android?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1138045.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存