本文整理匯總了Java中android.graphics.drawable.LayerDrawable.findDrawableByLayerId方法的典型用法代碼示例。如果您正苦於以下問題:Java LayerDrawable.findDrawableByLayerId方法的具體用法?Java LayerDrawable.findDrawableByLayerId怎麽用?Java LayerDrawable.findDrawableByLayerId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.LayerDrawable
的用法示例。
在下文中一共展示了LayerDrawable.findDrawableByLayerId方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changeBackground
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public void changeBackground() {
if (iSchecked) {
if (!isInEditMode()) {
setBackgroundResource(R.drawable.background_checkbox);
LayerDrawable layer = (LayerDrawable) getBackground();
GradientDrawable shape = (GradientDrawable) layer
.findDrawableByLayerId(R.id.shape_bacground);
shape.setColor(backgroundColor);
}
} else {
if (!isInEditMode()) {
setBackgroundResource(R.drawable.background_switch_ball_uncheck);
}
}
}
示例2: setBackgroundColor
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
@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
}
}
示例3: setColor
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void setColor(Drawable drawable, int color) {
if (drawable instanceof ShapeDrawable) {
((ShapeDrawable) drawable).getPaint().setColor(color);
} else if (drawable instanceof GradientDrawable) {
((GradientDrawable) drawable).setColor(color);
} else if (drawable instanceof ColorDrawable) {
((ColorDrawable) drawable).setColor(color);
} else if (drawable instanceof LayerDrawable) {
LayerDrawable layerDrawable = (LayerDrawable) drawable;
RotateDrawable rotateDrawable =
(RotateDrawable) layerDrawable.findDrawableByLayerId(R.id.carrot_shape_top);
setColor(rotateDrawable.getDrawable(), color);
} else if (drawable instanceof RotateDrawable) {
setColor(((RotateDrawable) drawable).getDrawable(), color);
}
}
示例4: changeBackground
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public void changeBackground() {
if (!isInEditMode()) {
if (value != min) {
setBackgroundResource(R.drawable.background_checkbox);
LayerDrawable layer = (LayerDrawable) getBackground();
GradientDrawable shape = (GradientDrawable) layer
.findDrawableByLayerId(R.id.shape_bacground);
shape.setColor(backgroundColor);
} else {
setBackgroundResource(R.drawable.background_switch_ball_uncheck);
}
}
}
示例5: setupBadgeBackgroundColors
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void setupBadgeBackgroundColors(String BADGE_COLOR) {
GradientDrawable gd = (GradientDrawable) outer_container.getBackground();
gd.setColor(Color.parseColor(BADGE_COLOR));
LayerDrawable layers = (LayerDrawable) bottom_arrow.getBackground();
RotateDrawable rotate = (RotateDrawable) layers.findDrawableByLayerId(R.id.grad);
GradientDrawable drawable = (GradientDrawable) rotate.getDrawable();
drawable.setColor(Color.parseColor(BADGE_COLOR));
}
示例6: setMaximumTrackTintColor
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
@ReactProp(name = "maximumTrackTintColor", customType = "Color")
public void setMaximumTrackTintColor(ReactSlider view, Integer color) {
LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent();
Drawable progress = drawable.findDrawableByLayerId(android.R.id.progress);
if (color == null) {
progress.clearColorFilter();
} else {
progress.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
}
示例7: setSeekBarBg
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void setSeekBarBg(){
try {
int progressColor = CustomAttrValueUtil.getAttrColorValue(R.attr.colorPrimary,R.color.colorAccent,this);
LayerDrawable layerDrawable = (LayerDrawable) seekBar.getProgressDrawable();
ScaleDrawable scaleDrawable = (ScaleDrawable)layerDrawable.findDrawableByLayerId(android.R.id.progress);
GradientDrawable drawable = (GradientDrawable) scaleDrawable.getDrawable();
drawable.setColor(progressColor);
}catch (Exception e){
e.printStackTrace();
}
}
示例8: setMinimumTrackTintColor
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
@ReactProp(name = "minimumTrackTintColor", customType = "Color")
public void setMinimumTrackTintColor(ReactSlider view, Integer color) {
LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent();
Drawable background = drawable.findDrawableByLayerId(android.R.id.background);
if (color == null) {
background.clearColorFilter();
} else {
background.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
}
示例9: init
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
void init(AttributeSet attrs, int defStyle) {
inflate(getContext(), R.layout.sv_slide_view, this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setBackground(ContextCompat.getDrawable(getContext(), R.drawable.sv_view_bg));
} else {
setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.sv_view_bg));
}
slideTextView = findViewById(R.id.sv_text);
slider = findViewById(R.id.sv_slider);
slider.setOnSeekBarChangeListener(this);
slideBackground = getBackground();
buttonLayers = (LayerDrawable) slider.getThumb();
buttonBackground = buttonLayers.findDrawableByLayerId(R.id.buttonBackground);
TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.SlideView,
defStyle, defStyle);
int strokeColor;
float slideTextSize = spToPx(16, getContext());
String slideText;
boolean reverseSlide;
ColorStateList sliderTextColor;
try {
animateSlideText = a.getBoolean(R.styleable.SlideView_sv_animateSlideText, true);
reverseSlide = a.getBoolean(R.styleable.SlideView_sv_reverseSlide, false);
strokeColor = a.getColor(R.styleable.SlideView_sv_strokeColor, ContextCompat.
getColor(getContext(), R.color.sv_stroke_color_default));
slideText = a.getString(R.styleable.SlideView_sv_slideText);
sliderTextColor = a.getColorStateList(R.styleable.SlideView_sv_slideTextColor);
slideTextSize = a.getDimension(R.styleable.SlideView_sv_slideTextSize, slideTextSize);
slideTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, slideTextSize);
setText(slideText);
setTextColor(sliderTextColor == null ? slideTextView.getTextColors() : sliderTextColor);
int buttonImageId = a.getResourceId(R.styleable.SlideView_sv_buttonImage, R.drawable.sv_ic_chevron_double_right);
setButtonImage(ContextCompat.getDrawable(getContext(), buttonImageId));
setButtonImageDisabled(ContextCompat.getDrawable(getContext(), a.getResourceId
(R.styleable.SlideView_sv_buttonImageDisabled, buttonImageId)));
setButtonBackgroundColor(a.getColorStateList(R.styleable.SlideView_sv_buttonBackgroundColor));
setSlideBackgroundColor(a.getColorStateList(R.styleable.SlideView_sv_slideBackgroundColor));
if (a.hasValue(R.styleable.SlideView_sv_strokeColor)) {
Util.setDrawableStroke(slideBackground, strokeColor);
}
if (reverseSlide) {
slider.setRotation(180);
LayoutParams params = ((LayoutParams) slideTextView.getLayoutParams());
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
params.addRule(RelativeLayout.ALIGN_PARENT_END, 0);
params.addRule(RelativeLayout.ALIGN_PARENT_START);
}
slideTextView.setLayoutParams(params);
}
} finally {
a.recycle();
}
}
示例10: Slider
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
/**
* Creates a new Slider component.
*
* @param container container that the component will be placed in
*/
public Slider(ComponentContainer container) {
super(container);
seekbar = new SeekBar(container.$context());
fullBar = (LayerDrawable) seekbar.getProgressDrawable();
beforeThumb = (ClipDrawable) fullBar.findDrawableByLayerId(R.id.progress);
leftColor = initialLeftColor;
rightColor = initialRightColor;
setSliderColors();
// Adds the component to its designated container
container.$add(this);
// Initial property values
minValue = Component.SLIDER_MIN_VALUE;
maxValue = Component.SLIDER_MAX_VALUE;
thumbPosition = Component.SLIDER_THUMB_VALUE;
thumbEnabled = true;
seekbar.setOnSeekBarChangeListener(this);
//NOTE(kashi01): The boundaries for Seekbar are between 0-100 and there is no lower-limit that could
// be set. We keep the SeekBar effectively at [0-100] and calculate thumb position within that
// range.
seekbar.setMax(100);
// Based on given minValue, maxValue, and thumbPosition, determine where the seekbar
// thumb position would be within normal SeekBar 0-100 range
// !!! check this. maybe don't want to pass the args???
setSeekbarPosition();
if (DEBUG) {
Log.d(LOG_TAG, "Slider initial min, max, thumb values are: " +
MinValue() + "/" + MaxValue() + "/" + ThumbPosition());
}
if (DEBUG) {
Log.d(LOG_TAG, "API level is " + SdkLevel.getLevel());
}
}
示例11: setProgressBarColor
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void setProgressBarColor(int dark) {
LayerDrawable ld = (LayerDrawable) progressSlider.getProgressDrawable();
ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
clipDrawable.setColorFilter(dark, PorterDuff.Mode.SRC_IN);
}
示例12: setProgressBarColor
import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public void setProgressBarColor(SeekBar progressBar, int newColor) {
LayerDrawable ld = (LayerDrawable) progressBar.getProgressDrawable();
ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
}