2015-04-24 36 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"