2013-03-16 41 views
0

我嘗試將ImageView添加到水平LinearLayout。它們應占用相同的空間,因此我將這些ImageView的重量設置爲1.它們按照我的預期佈置,但圖像變得粗糙。我將scapeType設置爲居中。 根據中心scaletype,他們不應該拉伸,但他們是,這是我的問題。 我的ImageView:Android ImageView鏈接

<ImageView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="3" 
    android:scaleType="centerInside" 
    android:adjustViewBounds="true"/> 

這是我加入他們:

for (int i = 0; i < badges.size() && i < 4; i++) { 
       Badge currentBadge = badges.get(i); 
       ImageView view = (ImageView) inflater.inflate(R.layout.listitem_badge, 
         mBadgesContainer, false); 
       view.setBackgroundResource(R.drawable.dummy_badge_medic); 
       mBadgesContainer.addView(view); 
      } 

的LinearLayout中:

<LinearLayout 
    android:id="@+id/container_badges" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/title_badges" 
    android:orientation="horizontal" /> 

回答

2

因爲你設置的ImageView背景,你可能有小的圖像在drawable

嘗試設置srcview.setImageResource(R.drawable.dummy_badge_medic);

+0

OMG。那簡直是愚蠢的。 – gmate 2013-03-17 07:19:04