【问题标题】:Rounded button color picker in androidandroid中的圆形按钮颜色选择器
【发布时间】:2018-05-06 14:18:38
【问题描述】:

我想为我的应用程序提供一个圆形按钮颜色选择器,如下所示。

我尝试过的是这个。创建这么多具有​​不同背景颜色的圆形按钮。好像效率有点低。单击按钮将选择颜色。有一个更好的方法吗 ?

//rounded.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#ff0000" />
    <corners android:bottomRightRadius="35dp"
        android:bottomLeftRadius="35dp"
        android:topRightRadius="35dp"
        android:topLeftRadius="35dp"/>
</shape>

//In Layout
    <Button
        android:id="@+id/button2"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:background="@drawable/roundedbutton"
        android:text="Button" />

【问题讨论】:

    标签: android color-picker


    【解决方案1】:

    你可以使用FloatingActionButton

    浮动操作按钮 (FAB) 是一个圆形按钮,可触发应用 UI 中的主要操作

    浮动操作按钮用于特殊类型的提升操作。它们通过悬浮在 UI 上方的带圆圈图标来区分,并具有与变形、发射和转移锚点相关的特殊运动行为。

    <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|bottom"
            android:src="@drawable/ic_my_icon"
            android:layout_margin="16dp" />
    

    编辑

    对于颜色选择器,您可以使用以下库

    【讨论】:

    • 请阅读问题。我不需要浮动按钮。我需要颜色选择器。如附图所示,我已经看到一些使用颜色选择器的应用程序。
    • @YesudassMoses 你可以使用颜色选择器库
    • 谢谢@Nilesh。
    • @YesudassMoses 很乐意帮助你
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-05
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多