【问题标题】:How to achieve glow effect on focused icon in Android?如何在Android中实现焦点图标的发光效果?
【发布时间】:2021-10-07 01:18:58
【问题描述】:

我想在这张图片上显示类似的光芒

我知道如何使用Palette 获得主色。我想知道如何显示这样的发光效果。

【问题讨论】:

    标签: android android-studio kotlin android-layout


    【解决方案1】:

    几天前我使用第三方library 做了类似的事情。按照初始步骤添加来自 here 的依赖项和 maven。

    下面是发光按钮的xml 代码。

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:gravity="center"
        android:background="@color/black"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    
        <com.smb.glowbutton.GlowButton
            android:id="@+id/myGlowButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginHorizontal="16dp"
            android:layout_marginTop="8dp"
            app:gb_drawablePadding="50dp"
            app:gb_drawableTint="@color/black"
            android:paddingTop="5dp"
            android:paddingBottom="5dp"
            app:gb_text="Prime Video"
            app:gb_textColor="@color/white"
            app:gb_textSize="16dp"
            app:gb_backgroundColor="#305B7B"
            app:gb_cornerRadius="15dp"
            app:gb_disabledTextColor="#808080"
            app:gb_glowAnimationDuration="500"
            app:gb_glowColor="#305B7B"
            app:gb_rippleAnimationDuration="1500"
            app:gb_rippleColor="#305B7B"
            app:gb_rippleEnabled="true" />
    
    </LinearLayout>
    

    输出

    希望对你有帮助。

    【讨论】:

    • 我们可以在其中添加图片吗?
    • 对不起,我没试过。你可以自己查。
    猜你喜欢
    • 1970-01-01
    • 2011-09-24
    • 1970-01-01
    • 1970-01-01
    • 2011-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多