Android LinearLayout布局控件靠右

Stella981
• 阅读 419

这是个悲伤而又略带绝望的故事,发生在我和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>

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

Android LinearLayout布局控件靠右

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

android:layout_gravity="center_vertical|right"

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

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

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
东方客主 东方客主
3年前
Android输入法遮挡了输入框,使用android:fitsSystemWindows="true"后界面顶部出现白条
问题1、页面布局文件:<LinearLayoutxmlns:android"http://schemas.android.com/apk/res/android"android:id"@id/layoutorderdetail"android:layoutwidth"matchparent"android:layoutheigh
Wesley13 Wesley13
2年前
android WebView 使用实例
主布局文件:<?xmlversion"1.0"encoding"utf8"?<LinearLayoutxmlns:android"http://schemas.android.com/apk/res/android"android:layout_width"match_parent"
Stella981 Stella981
2年前
Spinner使用
1.在xml文件设立布局文件<Spinner    android:layout\_width"wrap\_content"    android:layout\_height"wrap\_content"    android:layout\_below"@id/b1"    andro
Stella981 Stella981
2年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Stella981 Stella981
2年前
Android So动态加载 优雅实现与原理分析
背景:漫品Android客户端集成适配转换功能(基于目标识别(So库35M)和人脸识别库(5M)),导致apk体积50M左右,为优化客户端体验,决定实现So文件动态加载.!(https://oscimg.oschina.net/oscnet/00d1ff90e4b34869664fef59e3ec3fdd20b.png)点击上方“蓝字”关注我
Easter79 Easter79
2年前
Twitter的分布式自增ID算法snowflake (Java版)
概述分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的。有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。而twitter的snowflake解决了这种需求,最初Twitter把存储系统从MySQL迁移
Wesley13 Wesley13
2年前
Unity横屏
Android下发现Unity里面的Player设置,并不能完全有效,比如打开了自动旋转,启动的时候还是会横屏,修改XML添加以下代码<applicationandroid:icon"@drawable/ic\_launcher"                    android:label"@string/app\_name"
Stella981 Stella981
2年前
Android选项卡TabHost功能和用法
1、布局文件<TabHostxmlns:android"http://schemas.android.com/apk/res/android"xmlns:tools"http://schemas.android.com/tools"android:id"@android:id/tabhost"
Python进阶者 Python进阶者
3个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这