如何设置水平线的最大宽度LinearLayout
?因此,如果内容较短(例如某些文本),布局会缩小,如果内容较长,则布局不会扩展超过某个最大宽度值。
我更喜欢在 XML 级别执行此操作。
这就是我所需要的超出了之前答案中的建议 https://stackoverflow.com/a/3702533/839601是添加另一个布局(@+id/TheLayout
)作为内容和顶部布局之间的包装:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="100dip"
android:paddingRight="100dip">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/TheLayout"
android:layout_gravity="right">
<TextView android:id="@+id/TextView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:text="this is my text."
android:layout_gravity="center_vertical">
</TextView>
<ImageView android:id="@+id/ImageView01"
android:layout_height="wrap_content"
android:background="@drawable/icon"
android:layout_width="fill_parent">
</ImageView>
</LinearLayout>
</LinearLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)