2011-03-24 38 views
2

我遇到列表視圖及其項目的問題。當向上/向下滾動列表視圖時,我注意到項目稍微調整大小(大約一個像素),在我的應用程序中,它看起來像^。兩個項目之間的分隔線應該是一個像素高(使用默認的Android行爲),但當滾動分隔線有時是2像素或0像素(不可見)。這是不好的,因爲它看起來像兩個項目形成一個列表項目。Android列表視圖:滾動以奇怪的方式調整項目大小

有沒有人在滾動ListView時出現這個奇怪的調整大小問題的解決方案?

我的開發設備是帶有固件版本2.1-update1的HTC Wildfire。模擬器設置爲:Android 2.1-update1,外觀WVGA800和hw.lcd.density = 240。

ListView控件充滿以下項目佈局和我使用默認設置爲ListView:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="?android:attr/listPreferredItemHeight" 
android:background="#F0F0F0"> 
    <ImageView 
     android:id="@+id/test_icon" 
     android:layout_height="fill_parent" 
     android:layout_width="wrap_content" 
     android:src="@drawable/icon" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:scaleType="centerInside"> 
    </ImageView> 
    <TextView 
     android:id="@+id/testTextView1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentTop="true" 
     android:layout_alignWithParentIfMissing="true" 
     android:layout_toLeftOf="@+id/test_icon" 
     android:text="test" 
     android:textColor="#555555" /> 
</RelativeLayout> 

謝謝!

+0

這是否發生在仿真器和真實設備上? – Blundell 2011-03-24 11:06:39

+0

是的,它發生在我的模擬器和設備上 – Delblanco 2011-03-24 12:52:37

回答

0

嘗試將文本項目是width="wrap_content"

1

嘗試設置安卓重力中心|填寫無論是外部因素還是內部的人上。這固定了一個我正在調整大小的滾動問題。

+0

這可能有所幫助。下次我嘗試你的答案,因爲我的項目已經結束。我最終創建了一個解決方法,在每個單元格內放置我自己的divider圖像或至少2px的strok。這確保了分頻器總是至少1px。 android sdk內部的計算有時最終會低於1個像素,並且在將它們轉換爲實際像素時會丟失。 – Delblanco 2011-07-15 07:38:00

相關問題