android - Android 中的圆形按钮颜色选择器

标签 android color-picker

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

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

//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" />

enter image description here

最佳答案

你可以使用 FloatingActionButton

A floating action button (FAB) is a circular button that triggers the primary action in your app's UI

Floating action buttons are used for a special type of promoted action. They are distinguished by a circled icon floating above the UI and have special motion behaviors related to morphing, launching, and the transferring anchor point.

<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" />

编辑

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

关于android - Android 中的圆形按钮颜色选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50200698/

相关文章:

android - Facebook 申请请求

java - 如何动态设置主题?

javascript - 如何在IE中制作颜色选择器?

iphone - 如何在 ios 中获取自定义颜色的 RGB 分量

javascript - 为什么这个 JQuery 拾色器插件没有包含在我的网页中/未被检测到?

android - TextInputEditText 无法转换为 TextInputLayout

android - 我应该在所有地方为所有小部件使用 Roboto 字体吗?

Android ICS 网络位置未更新

java - Android 4.0 中 SSL 客户端身份验证被破坏

javascript - 是否有适用于 Windows 8 的内置颜色选择器(javascript)