【发布时间】:2012-11-07 21:12:53
【问题描述】:
我有一个 ViewFlipper 可以在 2 个视图之间翻转,一个是 ImageView,一个是 TextView。
图像和文本的大小取决于我从服务器检索到的内容。
我希望 TextView 始终具有与 ImageView 相同的高度尺寸,以便在翻转 ImageView 时 TextView 布局的大小不会改变,即使与 TextView 关联的文本很少;如果有很多文本,如果 TextView 的高度超过 ImageView,我想做一个 ellipsize="end"。
以下是我在布局中使用的代码:
<ViewFlipper
android:id="@+id/flipperZoneMediumLeft"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgZonePic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/stock_service1"
android:background="@android:color/black"
android:scaleType="center" />
<TextView
android:id="@+id/txtZoneNameFlipperLeft"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:text="This is a description"
android:background="@android:color/black"
android:textColor="@android:color/white" />
</ViewFlipper>
我觉得这个问题有一个简单的解决方案,但我在这条路上挣扎太久了。任何帮助解决我的问题将不胜感激。
【问题讨论】:
标签: android android-layout viewflipper