Android LinearLayout布局控件靠右

这是个悲伤而又略带绝望的故事,发生在我和xml布局之间,他气死了我,我删了它。

我说 靠右。

控件非不。

全剧终。

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@drawable/bg_personal_major_experience_item_shape"
        android:layout_marginTop="@dimen/y30"
        android:layout_marginLeft="@dimen/x30"
        android:layout_marginRight="@dimen/y30">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="@dimen/y122"
            android:orientation="horizontal">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:layout_weight="1">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="教育背景"
                    android:textColor="@color/colorBlue"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="@dimen/x60"
                    android:textSize="20dp"/>
            </LinearLayout>
           <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:orientation="horizontal"
              <!-- android:gravity="right" -->
               android:layout_weight="1">
               <ImageView
                   android:layout_width="@dimen/x45"
                   android:layout_height="@dimen/y45"
                   android:layout_gravity="center_vertical"
                   android:layout_marginRight="@dimen/x60"
                   android:src="@mipmap/p_add"/>
           </LinearLayout>

        </LinearLayout>

上面就是我的布局文件,长下面这个鸟样,

102550_h0LD_2276921.png

我的目的是想把那个中间的加号放到右边去,不要问我为什么这么傻逼用了layout_weight 这也是被逼的没办法之后的一个尝试。网上说这样可以,然而并没有什么卵用,设置成 

android:layout_gravity="center_vertical|right"

这样都没有任何效果,我只是想把控件摆到右边去,多简单的一件事,直接margin_right不行么!!!Android布局什么鬼,特么气死我了。

后来又百度了一下,是需要在LinearLayout里面吧gravity设置为right这样才行,也就是我上面注释掉的那行。蛋疼,可能我的想法其实更适合用RelativeLayout吧。

转载于:https://my.oschina.net/u/2276921/blog/759884

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值