2010-08-25 30 views
1

朋友的 我有一個任務來解析縮略圖並將其設置在網格視圖上,其中url圖像內容將在不同的高度和寬度(一些圖像爲60 * 60 ,或110 * 80),我如何設置網格中的圖像具有統一的高度和寬度。如何設置網格圖像具有統一的高度和寬度

在此先感謝。

回答

1

給您的用於由ListAdapter創建一個固定的寬度和高度足夠使最大尺寸的觀點佈局,然後定位內部例如爲中心的ImageView的:

<RelativeLayout 
    android:id="@+id/RelativeLayout01" 
    android:layout_width="100dip" 
    android:layout_height="80dip"  
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <ImageView 
      android:id="@+id/imageView" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:scaleType="centerInside"> 
    </ImageView> 
</RelativeLayout> 
+0

非常感謝..你的答案,我真的得到了查看我需要你的幫助。 – MGSenthil 2010-08-25 18:28:44

0

給您的佈局由ListAdapter創建的視圖一個固定的寬度和高度足以最大的尺寸,然後放置內如爲中心的ImageView的:

   <GridView 
       android:id="@+id/gridView1" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_margin="4dp" 
       android:columnWidth="100dp" 
       android:horizontalSpacing="10dp" 
       android:verticalSpacing="10dp" 
       android:gravity="center" 
       android:numColumns="10" 
       android:stretchMode="columnWidth"/> 
+0

非常感謝您的回答,這對我非常有幫助 – 2016-03-22 05:41:21

0
<HorizontalScrollView 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/seatLegendLayout"> 

    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:id="@+id/linearLayout_gridtableLayout" 
      android:layout_width="900dp" 
      android:layout_height="match_parent" 
      android:orientation="horizontal"> 

      <GridView 
       android:id="@+id/gridView1" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_margin="4dp" 
       android:columnWidth="100dp" 
       android:gravity="center" 
       android:numColumns="9" 
       android:horizontalSpacing="1dp" 
       android:scrollbarAlwaysDrawHorizontalTrack="true" 
       android:scrollbarAlwaysDrawVerticalTrack="true" 
       android:scrollbars="horizontal" 
       android:stretchMode="none" 
       android:verticalSpacing="1dp"> 

      </GridView> 


     </LinearLayout> 
    </FrameLayout> 
</HorizontalScrollView> 
+0

對我來說,好的回答非常糟糕 – 2016-03-23 13:05:52

相關問題