这是个悲伤而又略带绝望的故事,发生在我和xml布局之间,他气死了我,我删了它。
我说 靠右。
控件非不。
全剧终。
1 <LinearLayout 2 android:layout_width="match_parent" 3 android:layout_height="wrap_content" 4 android:orientation="vertical" 5 android:background="@drawable/bg_personal_major_experience_item_shape" 6 android:layout_marginTop="@dimen/y30" 7 android:layout_marginLeft="@dimen/x30" 8 android:layout_marginRight="@dimen/y30"> 9 <LinearLayout 10 android:layout_width="match_parent" 11 android:layout_height="@dimen/y122" 12 android:orientation="horizontal"> 13 <LinearLayout 14 android:layout_width="match_parent" 15 android:layout_height="match_parent" 16 android:orientation="horizontal" 17 android:layout_weight="1"> 18 <TextView 19 android:layout_width="wrap_content" 20 android:layout_height="wrap_content" 21 android:text="教育背景" 22 android:textColor="@color/colorBlue" 23 android:layout_gravity="center_vertical" 24 android:layout_marginLeft="@dimen/x60" 25 android:textSize="20dp"/> 26 </LinearLayout> 27 <LinearLayout 28 android:layout_width="match_parent" 29 android:layout_height="match_parent" 30 android:orientation="horizontal" 31 <!-- android:gravity="right" --> 32 android:layout_weight="1"> 33 <ImageView 34 android:layout_width="@dimen/x45" 35 android:layout_height="@dimen/y45" 36 android:layout_gravity="center_vertical" 37 android:layout_marginRight="@dimen/x60" 38 android:src="@mipmap/p_add"/> 39 </LinearLayout> 40 41 </LinearLayout>
上面就是我的布局文件,长下面这个鸟样,

我的目的是想把那个中间的加号放到右边去,不要问我为什么这么傻逼用了layout_weight 这也是被逼的没办法之后的一个尝试。网上说这样可以,然而并没有什么卵用,设置成
android:layout_gravity="center_vertical|right"
这样都没有任何效果,我只是想把控件摆到右边去,多简单的一件事,直接margin_right不行么!!!Android布局什么鬼,特么气死我了。
后来又百度了一下,是需要在LinearLayout里面吧gravity设置为right这样才行,也就是我上面注释掉的那行。蛋疼,可能我的想法其实更适合用RelativeLayout吧。