Android 如何使用不同权重(如百分比宽度)的内容填充版面?
我有总重量为10的水平布局。 我想在上面放一些不同宽度的内容。 我希望我的内容看起来像它的宽度的下一个比例: 3:5:1:1 i、 e.像一个包含30%、50%、10%、10%列的表格 如何组织? 现在我有:Android 如何使用不同权重(如百分比宽度)的内容填充版面?,android,android-layout,android-linearlayout,textview,Android,Android Layout,Android Linearlayout,Textview,我有总重量为10的水平布局。 我想在上面放一些不同宽度的内容。 我希望我的内容看起来像它的宽度的下一个比例: 3:5:1:1 i、 e.像一个包含30%、50%、10%、10%列的表格 如何组织? 现在我有: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="ma
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:baselineAligned="true"
android:clipChildren="false"
android:orientation="horizontal"
android:useLargestChild="true"
android:weightSum="10" >
和具有不同权重的文本视图,如下所示:
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:layout_weight="3"
android:padding="2dp"
android:text="TextView 1"
android:textAppearance="?android:attr/textAppearanceMedium" />
但它不起作用。视图位于屏幕外。
如果我将match_parent更改为wrap_内容,当我不在其上放置大文本时,它看起来还可以,那么TextView就会增长。
我不想要它,我只想显示文本的那一部分,它将以当前的30%或50%等百分比进行包装。您将
android:layout\u width=“match\u parent”
设置为android:layou width=“0dp”
我在容器中使用
android:maxEms="<Wieght of this TextView>"
android:maxEms=“”
看起来不错。但我不确定它是否正确。请参见此处的类似问题: