Android——实现两个控件水平居中
16lz
2021-01-23
效果图:
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <RelativeLayout android:layout_marginTop="80sp" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@+id/center" android:textSize="20dp" android:text="左"/> <View android:id="@+id/center" android:layout_width="3dp" android:layout_height="40dp" android:layout_centerInParent="true" android:background="#ff0303"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/center" android:textSize="20dp" android:text="右"/> </RelativeLayout> </LinearLayout>
android:layout_toRightOf 在该id控件的右方
android:layout_toLeftOf 在该id控件的左方
更多相关文章
- Android ListView控件基本用法
- Android的文本系列的控件
- android 控件属性大全
- 【Android】Android控件之Seekbar拖动条的使用
- android linearlayout 把控件view置底部(放在页面最下方)
- Android 之 自定义控件用法介绍
- Form表单组合控件