【问题标题】:How to use this design in my app?如何在我的应用程序中使用这种设计?
【发布时间】:2017-07-22 12:26:48
【问题描述】:

如何实现下面链接中给出的设计。

我尝试了不同的流布局库,但它们缺乏自定义。提前致谢

【问题讨论】:

  • 一个简单的图片按钮就可以搞定。
  • 我建议在ScrollView 中使用GridView
  • 对我来说看起来像 FlowLayout。
  • 向我推荐一个很好的流布局库,可以进行大多数自定义。

标签: android android-layout flowlayout


【解决方案1】:

您可以像这样创建这种类型的设计:
创建如下布局

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_weight="1"
            android:background="@drawable/custom_button"
            android:drawableLeft="@drawable/ic_calender"
            android:text="button 1" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_weight="1"
            android:background="@drawable/custom_button"
            android:drawableLeft="@drawable/ic_calender"
            android:text="button 1" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_weight="1"
            android:background="@drawable/custom_button"
            android:drawableLeft="@drawable/ic_calender"
            android:text="button 1" />

    </LinearLayout>
</LinearLayout>

现在在 res/drawable 目录中创建这个可绘制的 custom_button

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <stroke android:width="2dp" android:color="@color/colorPrimary" />
        <corners android:radius="50dp" />
        <solid android:color="@color/colorPrimary" />
    </shape>
</item>

【讨论】:

    猜你喜欢
    • 2021-05-24
    • 2011-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-03
    • 2016-06-23
    相关资源
    最近更新 更多