Android: ширина изображения ImageView и подгонка исходного изображения - PullRequest
2 голосов
/ 28 июля 2011

У меня есть страница.Он загружает изображения с сервера и отображается на экране в парах по четыре.Некоторые изображения больше и меньше по размеру.Проблема в том, что когда изображение большое, изображение растягивается до фактического размера изображения.Я хочу, чтобы размер изображения соответствовал размеру изображения, не мешая другим 3 изображениям.Его xml - "

<LinearLayout android:id="@+id/videolist"
              android:orientation="vertical"
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent"
              android:layout_below="@+id/trendingnowmanual"
              android:layout_above="@+id/navigatevideo"
              android:gravity="center_vertical|center_horizontal"
              android:background="#ffffff"
              android:layout_marginLeft="20dip"
              android:layout_marginRight="20dip"
              android:layout_marginTop="5dip"
              android:layout_marginBottom="5dip"   >

                <LinearLayout android:layout_width="fill_parent" 
                              android:layout_height="wrap_content"
                              android:gravity="center_vertical|center_horizontal"
                              android:layout_marginLeft="10dip"
                              android:layout_marginRight="10dip"
                              android:layout_marginTop="10dip"
                              android:layout_marginBottom="5dip"
                              android:layout_weight="100">
                              <ImageView android:id="@+id/one"
                                         android:src="@drawable/add1"
                                         android:layout_width="wrap_content"
                                         android:layout_height="wrap_content"
                                         android:paddingRight="5dip"
                                         android:layout_weight="50"
                                         android:adjustViewBounds="true"
                                           >
                              </ImageView>
                              <ImageView android:id="@+id/two"
                                         android:src="@drawable/add2"
                                         android:layout_width="wrap_content"
                                         android:layout_height="wrap_content"
                                         android:paddingLeft="5dip"
                                         android:layout_weight="50"
                                         android:adjustViewBounds="true"
                                          >
                              </ImageView>

                </LinearLayout>             
                <LinearLayout android:layout_width="fill_parent" 
                              android:layout_height="wrap_content"
                              android:gravity="center_vertical|center_horizontal"
                              android:layout_marginLeft="10dip"
                              android:layout_marginRight="10dip"
                              android:layout_marginTop="5dip" 
                              android:layout_marginBottom="10dip"
                              android:layout_weight="100"  >
                              <ImageView android:id="@+id/three"
                                         android:src="@drawable/add3"
                                         android:layout_width="wrap_content"
                                         android:layout_height="wrap_content"
                                         android:paddingRight="5dip"
                                         android:layout_weight="50"
                                         android:adjustViewBounds="true"
                                           >
                              </ImageView>
                              <ImageView android:id="@+id/four"
                                         android:src="@drawable/add4"
                                         android:layout_width="wrap_content"
                                         android:layout_height="wrap_content"
                                         android:paddingLeft="5dip"
                                         android:layout_weight="50"
                                         android:adjustViewBounds="true"
                                           >
                              </ImageView>
                 </LinearLayout>
    </LinearLayout>

Есть идеи?

1 Ответ

4 голосов
/ 28 июля 2011

используйте scaleType = "fitXY" в вашем изображении

...