如何将多行文字共同显示在一个布局的正中间

1. 概述

在开发中,针对于下边2个大的红色框框中的布局是非常常见的,就是让小红框中的多行文字显示正中间,这里只是记录下自己针对于这种布局的写法


图片.png
思路如下:
    1.  首先最外层的大的红色框是一个RelativeLayout布局;
    2.  然后让右边的小车车图标放在最右边;
    3.  然后用一个LinearLayout包裹中间的多行文字,然后让这个LinearLayout垂直居中并且居于图标左边;
2. 代码写法

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="@dimen/px200"
                android:background="@color/bg_common_color"
                >

                <ImageView
                    android:layout_width="@dimen/px120"
                    android:layout_height="@dimen/px120"
                    android:src="@mipmap/ic_launcher"
                    android:layout_centerVertical="true"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="@dimen/px80"
                    android:id="@+id/iv_shop_icon"
                    />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/ll_deliver_goods"
                    android:layout_centerVertical="true"
                    android:orientation="vertical"
                    android:layout_toLeftOf="@id/iv_shop_icon"
                    >


                <cn.uploo.yhh.view.CustomTextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="卖家已发货"
                    android:textSize="@dimen/text_36"
                    android:textColor="@color/white"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="@dimen/px80"
                    />

                <include layout="@layout/activity_deliver_goods"/>

                </LinearLayout>

            </RelativeLayout>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容