您的位置:首页 > 移动开发 > Android开发

android:layout_gravity="right"控制LinearLayout中控件居右显示失败

2016-09-15 17:28 615 查看
相信大家在开发的时候肯定遇到android:layout_gravity=”right”控制LinearLayout中控件居右显示失败的问题,原因是此属性只能控制线性布局中一个控件的时候有效,当出现过个控件的时候该咋办?比如说3个的时候,此时就可以把中间的空间用 android:layout_weight=”1”

android:layout_width=”0dp”来控制了,指的是剩下的都是中间的,不叨叨,直接上代码

<LinearLayout
android:id="@+id/ll_mima_denglu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/view1_denglu"
android:orientation="horizontal">

<ImageView
android:layout_marginLeft="10dp"
android:layout_marginRight="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/mima"/>

<EditText
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="null"
android:hint="请输入密码"/>
<TextView
android:layout_gravity="right"
android:text="忘记密码?"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</LinearLayout>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 布局