LinearLayout
参考文章《第一行代码》
android:layout_weight="1" //占该行的权重(Button未设置)100%
android:orientation="horizontal" //线性布局方向 horizontal vertical
android:layout_width="match_parent"
//宽度: match_parent(屏幕大小) wrap_content(组件够用)
/*
当LinearLayout的方向是horizontal时
子控件宽度android:layout_width 不能是match_parent
因为一个控件就会充满屏幕 其他子控件无法显示
同理LinearLayout的方向是vertical时
子空间高度android:layout_height 不能是match_parent
*/
android:layout_gravity="center_horizontal"
// 控件在布局中的对齐方式
/*
如果布局对齐方式orientation是horizontal时 子控件layout_gravity
只有在vertical方向上有效
反之亦然
*/
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="账号/手机号码/邮箱"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入"
android:textSize="20sp"
android:textAllCaps="false"
/>
</LinearLayout>
效果