如何使用 4 个图标创建 android 应用程序主屏幕?
How to create android app home screen with 4 icons?
我有 4 个图标。我想创建 4 个带有图标的矩形。我还想在图标下方添加文字。我应该使用哪些组件?如何实施?
我尝试了 GridLayout 和 TableLayout,但我不知道该怎么做。
我想使用 material 设计来设计本机应用程序。
我在 photoshop 中设计了演示仪表板。我的应用程序主屏幕应如下所示
请帮忙!我是 android 初学者。
已编辑试试这个代码...
<?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>
您可以通过以下步骤简单地通过 LinearLayout 完成上述任务
1.divide 垂直布局分为四部分(第一和第三部分用于图像,第二和第四部分用于文本)
2.divide 每个垂直部分分为 2 个水平部分。
我用同样的方法完成了类似的任务,它对我来说非常有效。
我有 4 个图标。我想创建 4 个带有图标的矩形。我还想在图标下方添加文字。我应该使用哪些组件?如何实施? 我尝试了 GridLayout 和 TableLayout,但我不知道该怎么做。 我想使用 material 设计来设计本机应用程序。
我在 photoshop 中设计了演示仪表板。我的应用程序主屏幕应如下所示
请帮忙!我是 android 初学者。
已编辑试试这个代码...
<?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>
您可以通过以下步骤简单地通过 LinearLayout 完成上述任务 1.divide 垂直布局分为四部分(第一和第三部分用于图像,第二和第四部分用于文本) 2.divide 每个垂直部分分为 2 个水平部分。
我用同样的方法完成了类似的任务,它对我来说非常有效。