如何设置网格图像具有均匀的高度和宽度

时间:2010-08-25 10:48:51

标签: android

朋友的     我有一个任务来解析缩略图并将其设置在网格视图上,其中url图像内容在不同的高度和宽度(一些图像为60 * 60或110 * 80),我如何在网格中设置图像均匀的高度和宽度。

提前致谢。

3 个答案:

答案 0 :(得分: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>

答案 1 :(得分: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"/>

答案 2 :(得分: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>
相关问题