我设计布局如下线性布局包装的TextView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/messageText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Some really long text asd asd asd asd asd asd asd asd asd asd asd![enter image description here][1]" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12:45 PM" />
</LinearLayout>
它给像上面的UI ......
这是完美的我所需要的。由于方向是水平的,所以长按钮不会将屏幕按压离开屏幕。按钮也不拉伸。
但是,如果文字很小。它看起来像这样
我要的是按钮应该这样
我知道,因为我把布局权重为1对齐文本的左端。
在给按钮提供需要的空间后,它会消耗剩下的整个区域。
如果我不这样做。并使宽度成为包装内容。它适用于短文本。但随着文字的增长。
它将按钮从屏幕上推开。
那就是问题所在。 希望我让我的问题有足够的描述性。但当然要阅读很长时间。当然痛苦。 但是,真的很高兴知道任何指针。
我不愿意使用相对布局。
任何帮助将不胜感激。
谢谢
谢谢。拯救了我的夜晚:) – Javanator 2013-04-05 13:54:31