android线性布局左对齐,右对齐

 要求效果:

文本左对齐, 3个checkbox右对齐

 代码:

水平对齐,然后是用: weight这个属性来实现2边对齐

重点是:读取标签这个文本设置权重 :

android:layout_weight="1"

这样它就自动扩展充满剩余的空间,后面的3个多选框自动向右对齐 

 <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingEnd="6dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left"
                        android:padding="@dimen/regist_padding"
                        android:text="读取标签"
                        android:textColor="@color/fgm_toolbar_title"
                        android:textSize="@dimen/r_toolbar_title" />

                    <CheckBox
                        android:id="@+id/ignore_re_regist"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="忽略重新注册" />

                    <CheckBox
                        android:id="@+id/check_tag"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="6dp"
                        android:layout_marginRight="6dp"
                        android:text="条码校验" />

                    <CheckBox
                        android:id="@+id/write_pin"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="写芯片" />
                </LinearLayout>

                <View style="@style/registHorizontalDivider" />

            </LinearLayout>

猜你喜欢

转载自blog.csdn.net/LlanyW/article/details/131001887
今日推荐