2013-04-12 4 views
1

유니버설 이미지 로더를 사용하여 일부 이미지를 가져 와서 목록보기에 표시하고 있습니다. 레이아웃이 올바르게 보이지 않는데 문제가 있습니다. 이미지의 너비가 25 %를 넘지 않기를 바란다. Eclipse의 Graphical Layout보기에서보기에는 좋지만 이미지를 다운로드하면 너무 큰 전체 크기로 표시된다. 전체 너비가 무엇인지 알지 못해서 maxwidth을 사용하지 않기를 바랬습니다.유니버셜 이미지 로더가 layout_weight를 따르지 않습니다.

iv.setAdjustViewBounds(true); 

하는 가치가있을 수도 있습니다 :

이 내가 너무 UIL과 함께 사용되는 ImageViews의 크기가 몇 가지 문제가 있었다이 나를 도와

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="horizontal" 
android:padding="10dp" 
android:weightSum="100" > 

<ImageView 
    android:id="@+id/imgIcon" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_gravity="center_vertical" 
    android:layout_weight="25" 
    android:contentDescription="@string/offerImage" 
    android:paddingRight="10dip" 
    android:src="@drawable/ic_launcher" /> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="75" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/txtTitle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="5dp" 
     android:layout_marginTop="5dp" 
     android:text="tempString" 
     android:textColor="#ffffffff" 
     android:textSize="18sp" /> 

    <TextView 
     android:id="@+id/txtRetailer" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Business name" 
     android:textColor="#ffffffff" 
     android:textSize="16sp" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/txtDistance" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right" 
     android:text="99.99 miles" 
     android:textColor="#ffffffff" 
     android:textSize="12sp" 
     android:textStyle="bold" /> 
</LinearLayout> 

+0

ImageView의 scaleType 속성을 살펴볼 수 있습니다. http://developer.android.com/reference/android/widget/ImageView.ScaleType.html –

+1

'ImageView'와'LinearLayout' 둘 다'layout_width' 값을'0dip'으로 설정하려고 시도했습니다 –

+0

그 트릭을했습니다 :-) 고마워요 vmironov. 답으로 답장을하고 싶으면 받아 들일 것입니다. – Darren

답변

1

솔루션은 ImageViewLinearLayout 모두 0diplayout_width 값을 설정하는 것입니다 추가합니다. layout_weight은 사용되지 않은 공간에서만 작동하므로 이미지가 너무 큰 경우 여유 공간이 없습니다.

2

내 레이아웃 XML입니다 시도. XML 파일에서

+0

그게 작동하지 않는 것이 두려워요 .--( – Darren

0

는 이미지 뷰 태그이 추가 이

android:scaleType="fitXY" 
+0

fitXY는 종횡비를 변경할 수 있습니다. 원하지 않으면 fitStart를 사용해야합니다. –