Back to project page nxt-remote-controller.
The source code is released under:
MIT License
If you think the Android project nxt-remote-controller listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.gc.materialdesign.views; /*from w w w . j a v a2s . c o m*/ import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.widget.TextView; import com.gc.materialdesign.R; import com.gc.materialdesign.utils.Utils; public abstract class Button extends RippleView { public Button(Context context, AttributeSet attrs) { super(context, attrs); onInitAttributes(attrs); } @Override protected void onInitDefaultValues() { backgroundColor = Color.parseColor("#1E88E5");// ?????????? ///beforeBackground = backgroundColor;// error } protected void onInitAttributes(AttributeSet attrs) { setAttributes(attrs); } // ### RIPPLE EFFECT ### /** * @return ???bitmap */ public Bitmap makeCircle() { // ????????????????????????????????? Bitmap output = Bitmap.createBitmap( getWidth() - Utils.dpToPx(6, getResources()), getHeight() - Utils.dpToPx(7, getResources()), Config.ARGB_8888); return makeCircleFromBitmap(output); } // Set color of background @Override public void setBackgroundColor(int color) { backgroundColor = color; if (isEnabled()) { beforeBackground = backgroundColor; } try { LayerDrawable layer = (LayerDrawable) getBackground(); // ???????????drawable??xml??????xml???????item?id????shape_bacground GradientDrawable shape = (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground); /** * ???????????????????????????????????? * ??????????????????????????????????????????????????????????????? */ shape.setColor(backgroundColor); /** * ???????????????????????????????????????????????????????? */ if (!settedRippleColor) { rippleColor = makePressColor(255); } } catch (Exception ex) { // Without bacground } } abstract public TextView getTextView(); }