【发布时间】:2010-11-26 21:47:18
【问题描述】:
我已经为此苦苦挣扎了好几天,但我已经没有想法了。
在我的列表视图中,每一行都可以有一个垂直条向左刷新,根据状态不同颜色。该“栏”除了状态的视觉表示之外没有其他用途,并且不可点击。
我使用 ImageView 实现了垂直条,其背景设置为具有所需颜色的可绘制对象。问题是垂直条没有拉伸,即使我指定了 fill_parent,它也只有 1 个像素高。
行布局是这样的:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/id1"
android:scaleType="fitXY"
android:layout_width="5dp"
android:layout_height="fill_parent"
android:background="@drawable/d1" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/id1">
...
(为简单起见,故意将第二个相对布局的内容保留)
我的可绘制 d1 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/c1" />
<corners android:topRightRadius="5dip" android:bottomLeftRadius="5dip" />
</shape>
所以,
- 为什么 ImageView 没有垂直拉伸?
- 有没有更好的实现方式 这比使用 ImageView 吗? (一世 尝试了一个简单的视图 背景颜色,但不显示 完全没有)
非常感谢任何帮助。谢谢
【问题讨论】:
标签: android