0
我一直在爲此奮鬥了好幾天,而且我用盡了想法。Android ImageView不能在ListView行中垂直拉伸
在我的列表視圖中,每行都可以有一個豎條,用不同的顏色刷新,具體取決於狀態。該「酒吧」除了狀態的視覺表示沒有其他目的,並且不可點擊。
我使用ImageView實現了垂直條,背景設置爲具有所需顏色的drawable。問題是垂直條不伸展,即使我指定了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更好的實現 的方法? (我試過 一個簡單的查看與 背景顏色,但它並不顯示 根本上)
任何幫助極大的讚賞。謝謝
我有一個相對佈局,因爲實際上有一個文本視圖上方的對象,我省略xml保留這篇文章的簡短。我從您給我的鏈接中閱讀帖子,我已經在使用正確的方式來擴大視圖。不過,我將嘗試用多個LinearLayouts交換Relative佈局以查看是否修復了它。 – 2010-11-26 23:19:56