LinearLayout中的控件两端对齐
16lz
2021-01-26
在android中的控件LinearLayout 中的android:gravity="center" 属性,要么是居左、居右、居中对齐,不能达到双控件 两端对齐,
要实现两端对齐方式,要采用 中间增加一个控件的方式实现 ,并设置属性weight=1。
具体的布局文件如下:
<?xml version="1.0″ encoding="utf-8″?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button01" > </Button> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" /> <Button android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button02" > </Button></LinearLayout>
效果如图:
实现两个button按钮 两端对齐
更多相关文章
- android中使用自定义控件checkbox,ToggleButton,ProgressBar
- Android(安卓)- NullPointerException
- Android(安卓)EditText 密码输入框可见性设置。
- 自定义ViewGroup控件 textView 的ellipsize end 属性无效
- Android(安卓)学习路线
- 关于android.os.NetworkOnMainThreadException
- Android实现一个通用的PopupWindow
- Android(安卓)PullToRefresh下拉刷新控件的简单使用
- Android(安卓)获取OnItemClick事件中组件的内容