如何创建像图像中那样的布局?

二十面体

我想要这样的图像在此处输入图片说明但是当文本的长度不相等时,TextViews 之间的距离会发生变化,并且当单词太多时转到下一行。

在此处输入图片说明

我创建的布局的 xml 代码是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<LinearLayout
        
                android:padding="10dp"
                android:orientation="horizontal"
                android:minWidth="25px"
                android:minHeight="25px"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"                
                android:id="@+id/linearLayout1" >
                <TextView
                    android:textSize="12dp"
                    android:gravity="center_vertical |right"
                    android:drawableRight="@drawable/shape_rectangle"
                    android:drawablePadding="5dp"                    
                    android:layout_weight="33.66"
                    android:text=" text"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:id="@+id/textView3" />

                <TextView
                    android:textSize="12dp"
                    android:gravity="center_vertical |right"
                    android:drawableRight="@drawable/shape_rectangle"
                    android:drawablePadding="5dp"                    
                    android:layout_weight="33.66"
                    android:text="some text"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:id="@+id/textView2" />

                <TextView
                    android:textSize="12dp"
                    android:ellipsize="end"
                   android:gravity="center_vertical |right"
                    android:drawableRight="@drawable/shape_rectangle"
                    android:drawablePadding="5dp"                    
                    android:layout_weight="33.66"
                   android:text="some text with more word"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:id="@+id/textView1" />
        
            </LinearLayout>

            <View        
                android:background="#CCC"
                android:layout_width="match_parent"
                android:layout_height="2dp"/>

</LinearLayout>

如何在所有屏幕尺寸上使用不同的文本和稳定的布局?

贾夫德罗梅罗

您需要设置android:layout_width="match_parent"为所有的TextViews,如果所有的权重都相同,您可以为每个人设置 1,重要的是比率,而不是数字本身。

<TextView
            ...
            android:singleLine="true"
            android:ellipsize="end"
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/textView1" />

编辑:将android:singleLineandroid:singleLineattribute 添加到答案以匹配问题标准。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何设计一个像图像中描述的那样的滑块视图并通过URL传递图像

如何在页脚中左右放置文本,就像图像中的那样

如何为头像图像创建星形?

在.net中创建圆形头像图像

如何使图像图标在线性布局中正确对齐?

我想让我的电子邮件文本字段像图像中的那样

如何使用CSS单个元素创建镜像图像效果

如何在颤动中显示圆形头像图像?

如何在openlayers中优先显示图像图标?

如何使用Azure Devops API中的头像图像URL

如何在CSS中制作1个图像图块?

QML 中的图像图集

哪些布局管理器可以像图中那样排列 JPanel?

如何为头像图像创建五边形形状?

如何使用Snap.svg为路径创建图像图案?

带有圆形图像图标的颤振布局

将风景和肖像图像放入引导轮播:响应式布局中的高度和宽度

如何获得图像图上的跨度

d3 中的图像图

Toast Maketext消息中的图像图标

如何创建带有角度的设置按钮以及如何在相对布局中设置按钮图像

如何在 Delphi 11 中访问 TImageCollection 中的图像图片

<video>图像提要位于镜像中,如何将图像转换为非镜像图像

如何在 HTML 中的头像图像上添加点标记?

如何在Windows Phone 8.1的ToggleButton中显示图像图标而不是文本?

如何在C ++ BOOST中像图一样加载TIFF图像

如何在 mui reactjs 中显示抽屉外的头像图像?

如何在嵌套flexbox列布局中创建图像缩放效果?

如何在jetpack compose中为图像创建网格布局?