【问题标题】:Android Ripple Effect for my custom button我的自定义按钮的 Android 波纹效果
【发布时间】:2017-02-17 04:48:33
【问题描述】:

我已经创建了一个带有自定义按钮类的项目,如下所示。

package app.kibbeh.widget;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;

public class MyFontButton extends Button {
    private static final String TAG = "TextView";
    private Typeface typeface;

    public MyFontButton(Context context) {
        super(context);
    }

    public MyFontButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        setCustomFont(context, "");
    }

    public MyFontButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setCustomFont(context, "");
    }


    private boolean setCustomFont(Context ctx, String asset) {
        try {
            if (this.typeface == null) {
                Log.i(TAG, "asset:: fonts/" + asset);
                this.typeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/avenirroman.ttf");
            }
            setTypeface(this.typeface);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            Log.e(TAG, "Could not get typeface: " + e.getMessage());
            return false;
        }
    }
}

现在我必须从这里添加涟漪效果。那么有可能还是我必须在所有 xml 文件中添加 rippelview ?请指导我。 谢谢。。

【问题讨论】:

    标签: android button android-animation rippledrawable


    【解决方案1】:

    【讨论】:

    • 是的,我已经检查过了。它为我工作。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-27
    • 2021-06-26
    • 1970-01-01
    相关资源
    最近更新 更多