尝试使两个按钮之间的两个按钮和标题之间的工具栏。当文本太长时,标题应该是ellisized,如下所示:Android中的布局问题(两个按钮之间的椭圆化文本)
[Button] Some quite long header te... [Button]
我已经尝试了几种解决方案,但没有任何帮助。我最后一次尝试是这样的:
android:layout_height="wrap_content"
android:background="#444"
android:stretchColumns="1">
android:background="#f00"
android:lines="1"
android:ellipsize="end"
android:scrollHorizontally="true"
android:gravity="center"
/>
但右边的按钮还是那张从屏幕上移开......
UPDATE: 解决的办法是:
android:text="Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:text="Right"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#f00"
android:lines="1"
android:ellipsize="end"
android:gravity="center"
android:scrollHorizontally="true"
android:layout_toLeftOf="@id/btnRight"
android:layout_toRightOf="@id/btnLeft"
/>
更新2:而使用TableLayout的第二种解决方案:
android:layout_height="wrap_content"
android:background="#444"
android:stretchColumns="1"
android:shrinkColumns="1">
android:background="#f00"
android:lines="1"
android:ellipsize="end"
android:scrollHorizontally="true"
android:gravity="center"
/>