0

在我的应用程序中,我想要显示一系列小图像的一些活动,我的目标是纵向显示3行,横向显示5行,但我对这些数字并不严格。简单的方法来创建显示几十个图标?

第一个问题是,我找不出一个布局,或布局的配置,这将使我能够正确实现这种效果。我试过TableLayout,FrameLayout和RelativeLayouts,但没有一个让我的图像看起来很好地排列在两个方向。

在这种情况下,图像是标志。我试过用中间符号创建9个补丁,我不想被扭曲。 Android Studio不接受他们是.9文件。但这是一个单独的问题。

 <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/iceland" 
     android:layout_weight="0.25" 
     android:scaleType="fitXY" 
     android:id="@+id/imageView"/> 

我做了一个我想要实现的模型。我真的很感谢你们提供的任何提示。谢谢!

Flag App 1

Flag App 2

+0

你试过'GridView'吗? – kcoppock 2014-09-30 22:29:58

+0

就像@ kcoppock说的那样,尝试一个'GridView',并改变横向方向的列数。 – 2014-09-30 22:43:57

回答

0
<?xml version="1.0" encoding="utf-8"?> 
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridView1" 
    android:numColumns="auto_fit" 
    android:gravity="center" 
    android:columnWidth="50dp" 
    android:stretchMode="columnWidth" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

</GridView> 
this link应该提供的一个例子采取

,这可能是对你有用。