android - 如何创建带有 4 个图标的 Android 应用程序主屏幕?

标签 android android-layout material-design grid-layout dashboard

<分区>

我有 4 个图标。我想创建 4 个带有图标的矩形。我还想在图标下方添加文字。我应该使用哪些组件?如何实现? 我尝试了 GridLayout 和 TableLayout,但我不知道该怎么做。 我想使用 Material Design 设计本​​机应用程序。

我在 photoshop 中设计了演示仪表板。我的应用程序主屏幕应如下所示 enter image description here

求助!我是安卓初学者。

最佳答案

已编辑尝试此代码...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:background="@android:color/darker_gray"
            android:layout_weight="0.5">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/ic_launcher"
            android:layout_weight="0.5"/>
            </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:background="@android:color/black"
            android:layout_weight="0.5">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/ic_launcher"
                android:layout_weight="0.5"/>
        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:background="@android:color/black"
            android:layout_weight="0.5">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/ic_launcher"
                android:layout_weight="0.5"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:background="@android:color/darker_gray"
            android:layout_weight="0.5">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/ic_launcher"
                android:layout_weight="0.5"/>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

关于android - 如何创建带有 4 个图标的 Android 应用程序主屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34563462/

相关文章:

android - 是否有任何官方 API/示例/教程来实现新的 Material-Design-guidelines?

android - 缓存 SharedPreferences bool 值 : Would performance justify increased complexity?

Android - Gridview 图像在滚动时混合

android - 添加 cookie 以改造 2 请求

android - 从 google map api v2 中删除默认对象

android - GLSurfaceView 没有出现在 MapView 上

android - 找不到蜂窝开关开/关控制

android - 从 DDMS 编辑共享首选项

android - DividerItemDecoration 没有出现在 RecyclerView 中

android - CardView 在 Android L 中不显示阴影