當前位置: 首頁>>代碼示例>>Java>>正文


Java LayerDrawable.findDrawableByLayerId方法代碼示例

本文整理匯總了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);
		}
	}
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:17,代碼來源:Switch.java

示例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
	}
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:26,代碼來源:Button.java

示例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);
    }
}
 
開發者ID:harsh159357,項目名稱:InstaTag,代碼行數:17,代碼來源:InstaTag.java

示例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);
		}
	}
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:14,代碼來源:Slider.java

示例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));

    }
 
開發者ID:salRoid,項目名稱:InstaBadge,代碼行數:12,代碼來源:InstaBadgeView.java

示例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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:11,代碼來源:ReactSliderManager.java

示例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();
    }
}
 
開發者ID:lijunyandev,項目名稱:MeetMusic,代碼行數:12,代碼來源:PlayActivity.java

示例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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:11,代碼來源:ReactSliderManager.java

示例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();
    }
}
 
開發者ID:MAXDeliveryNG,項目名稱:slideview,代碼行數:65,代碼來源:SlideView.java

示例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());
  }

}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:47,代碼來源:Slider.java

示例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);
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:6,代碼來源:FlatPlaybackControlsFragment.java

示例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);
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:6,代碼來源:PlayerPlaybackControlsFragment.java


注:本文中的android.graphics.drawable.LayerDrawable.findDrawableByLayerId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。