【问题标题】:GridLayout design style with icons and text using material design?使用材料设计的带有图标和文本的 GridLayout 设计风格?
【发布时间】:2015-07-22 01:08:01
【问题描述】:

使用设计材料的支持库来实现带有文本的设计图标的最佳方法是什么。它看起来像上面链接的图像 enter link description here

【问题讨论】:

  • 嵌套LinearLayouts

标签: android android-layout


【解决方案1】:

正如 Karakuri 在 cmets 中所说,嵌套的 LinearLayouts 会像这样呈现您所需的视图

这是布局的代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:weightSum="3"
    android:padding="16dp"
    android:orientation="horizontal">


    <LinearLayout
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_repeat_48d"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Repeat"/>

    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_heart_48d"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Favourite"/>

    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_shuffle_48dp"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Shuffle"/>

    </LinearLayout>

</LinearLayout>

代码只是一个布局结构,你必须根据需要添加填充和ImageViewwidth-height。您必须为所需的布局做一些工作。如果您想要两行同样上传的图片,只需复制两次布局即可。

如果实施有任何问题,希望它有所帮助或发表评论。

干杯!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-24
    • 2016-07-18
    • 2015-12-07
    • 2017-06-09
    • 1970-01-01
    • 2015-09-02
    相关资源
    最近更新 更多