2015-04-24 37 views
0

我在ListView中顯示文本和圖像,圖像很小,但由於某些原因,它使所有圖像變大一點,所以它們很模糊,爲什麼不保持正常大小。ListView圖像保持伸展更大

我必須改變什麼

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center_vertical" 
    android:orientation="horizontal"> 

    <TextView 
     android:id="@+id/textView1" 
     android:textColor="@color/colorWhite" 
     android:layout_marginStart="10dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp"/> 

    <TextView 
     android:id="@+id/textView2" 
     android:textColor="@color/colorWhite" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp"/> 

    <TextView 
     android:id="@+id/textView3" 
     android:textColor="@color/colorWhite" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageView3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp"/> 

    <TextView 
     android:id="@+id/textView4" 
     android:textColor="@color/colorWhite" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageView4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp"/> 



</LinearLayout> 

</HorizontalScrollView> 
+0

你也可以使用ImageButton而不是ImageView進行檢查。 – User3

+0

您可以修復此寬度和高度。 –

回答

0

中的ImageView的XML添加這兩個屬性:

android:scaleType="fitXY" 
android:adjustViewBounds="true" 
-1

問題是你如何扭曲你的視圖元素,你要記住,與改變文本長度和圖像分辨率包裹元素將更改您的項目視圖,

計數器給出相關大小,有時您必須將它們限制到一定的大小。而且不要使用android:scaleType="fitXY" android:adjustViewBounds="true" 獲得縮放正確圖像,如果分辨率比的ImageView或圖像的限制大小將被剪切

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="50dp" 
    android:gravity="center_vertical" 
    android:orientation="horizontal" 
    android:layout_gravity="center"> 

    <TextView 
     android:id="@+id/textView1" 
     android:textColor="#fff" 
     android:layout_marginStart="10dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp"/> 

    <TextView 
     android:id="@+id/textView2" 
     android:textColor="#fff" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp"/> 

    <TextView 
     android:id="@+id/textView3" 
     android:textColor="#fff" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageView3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp"/> 

    <TextView 
     android:id="@+id/textView4" 
     android:textColor="#fff" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageView4" 
     android:layout_width="45dp" 
     android:layout_height="45dp" 
     android:scaleType="fitXY" 
     android:adjustViewBounds="true" 
     android:layout_marginStart="4dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp"/> 



</LinearLayout> 
0

更大加入

android:scaleType="fitXY" 

android:adjustViewBounds="true"