android显示布局边界的边距_Android LinearLayout布局控件靠右

本文讲述了在Android开发中遇到LinearLayout布局控件无法靠右显示及调整边距的问题,尝试使用layout_weight和layout_gravity属性未达到预期效果,最终通过在LinearLayout内设置gravity为right解决,同时表达了对Android布局复杂性的无奈。
摘要由CSDN通过智能技术生成

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

我说 靠右。

控件非不。

全剧终。

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">

android:layout_width="match_parent"

android:layout_height="@dimen/y122"

android:orientation="horizontal">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal"

android:layout_weight="1">

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"/>

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal"

android:layout_weight="1">

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"/>

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

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

android:layout_gravity="center_vertical|right"

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值