我在下面定义了一个布局,它呈现了两个视图-view 1和view 2。对于较小的屏幕尺寸,view 2是扭曲的。
问题-视图2需要出现在右侧,视图1将容纳左侧剩余的任何空间。视图2在尺寸方面非常恒定,可绘制性定义良好。
我该怎么做呢?先谢了。
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/view1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textSize="9pt"
android:layout_weight = "0"
android:maxWidth="260dp"
android:minWidth="260dp"/>
<TextView
android:id="@+id/view2"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="@drawable/some_drawable"/>
</LinearLayout>
我尝试了layout_width,但无法达到我想要的效果。我是android新手,任何指针也会很有帮助。
2条答案
按热度按时间bhmjp9jg1#
使用
机器人:布局权重="”
视图1使用**70%的屏幕(android:布局权重=“7”)
view2使用30%**的屏幕(android:布局权重=“3”)
e4eetjau2#
对于视图2保留
并为视图1设置以下内容:
这将使视图1在剩余宽度上扩展