【问题标题】:Simple way to create display a few dozen icons?创建显示几十个图标的简单方法?
【发布时间】:2014-09-30 22:26:20
【问题描述】:

在我的应用中,我想要一些显示一系列小图像的活动,我的目标是纵向每行 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"/>

我制作了我想要实现的目标的模型。我真的很感激你们能提供的任何建议。谢谢!

【问题讨论】:

  • 你试过GridView吗?
  • 就像@kcoppock 所说,尝试GridView,并在横向时更改列数。

标签: android android-layout android-studio imageview android-orientation


【解决方案1】:
<?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 应该提供一个可能对您有用的示例。

【讨论】:

    猜你喜欢
    • 2017-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-08
    • 1970-01-01
    • 2011-02-25
    相关资源
    最近更新 更多