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


Java LayerDrawable.mutate方法代碼示例

本文整理匯總了Java中android.graphics.drawable.LayerDrawable.mutate方法的典型用法代碼示例。如果您正苦於以下問題:Java LayerDrawable.mutate方法的具體用法?Java LayerDrawable.mutate怎麽用?Java LayerDrawable.mutate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.LayerDrawable的用法示例。


在下文中一共展示了LayerDrawable.mutate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clickBarOn

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void clickBarOn(FrameLayout frameLayout) {

		pins.get((int) frameLayout.getTag()).setVisibility(View.VISIBLE);

		isOldBarClicked = true;

		int childCount = frameLayout.getChildCount();

		for (int i = 0; i < childCount; i++) {

			View childView = frameLayout.getChildAt(i);
			if (childView instanceof LinearLayout) {

				LinearLayout linearLayout = (LinearLayout) childView;
				Bar bar = (Bar) linearLayout.getChildAt(0);
				TextView titleTxtView = (TextView) linearLayout.getChildAt(1);

				LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
				layerDrawable.mutate();

				ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

				GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();
				if (mPinBackgroundColor != 0) {
					if (progressLayer != null) {
						progressLayer.setColor(ContextCompat.getColor(mContext, mProgressClickColor));
					}

				} else {
					if (progressLayer != null) {
						progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.holo_green_dark));
					}
				}

				if (mBarTitleSelectedColor > 0) {
					titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleSelectedColor));
				} else {
					titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.holo_green_dark));
				}

			}
		}
	}
 
開發者ID:hadiidbouk,項目名稱:ChartProgressBar-Android,代碼行數:44,代碼來源:ChartProgressBar.java

示例2: disableBar

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public void disableBar(int index) {

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				if ((int) rootFrame.getTag() != index)
					continue;

				rootFrame.setEnabled(false);
				rootFrame.setClickable(false);

				View childView = rootFrame.getChildAt(j);
				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {

							Bar bar = (Bar) view;

							LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
							layerDrawable.mutate();

							ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

							GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();

							if (progressLayer != null) {

								if (mProgressDisableColor > 0)
									progressLayer.setColor(ContextCompat.getColor(mContext, mProgressDisableColor));
								else
									progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
							}
						} else {
							TextView titleTxtView = (TextView) view;
							if (mProgressDisableColor > 0)
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, mProgressDisableColor));
							else
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
						}
					}
				}
			}
		}
	}
 
開發者ID:hadiidbouk,項目名稱:ChartProgressBar-Android,代碼行數:59,代碼來源:ChartProgressBar.java

示例3: enableBar

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public void enableBar(int index) {

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				if ((int) rootFrame.getTag() != index)
					continue;

				rootFrame.setEnabled(true);
				rootFrame.setClickable(true);

				View childView = rootFrame.getChildAt(j);
				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {

							Bar bar = (Bar) view;

							LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
							layerDrawable.mutate();

							ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

							GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();

							if (progressLayer != null) {

								if (mProgressColor > 0)
									progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor));
								else
									progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
							}
						} else {
							TextView titleTxtView = (TextView) view;
							if (mProgressDisableColor > 0)
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor));
							else
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
						}
					}
				}
			}
		}
	}
 
開發者ID:hadiidbouk,項目名稱:ChartProgressBar-Android,代碼行數:59,代碼來源:ChartProgressBar.java

示例4: clickBarOff

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void clickBarOff(FrameLayout frameLayout) {

		pins.get((int) frameLayout.getTag()).setVisibility(View.INVISIBLE);


		isOldBarClicked = false;

		int childCount = frameLayout.getChildCount();

		for (int i = 0; i < childCount; i++) {

			View childView = frameLayout.getChildAt(i);
			if (childView instanceof LinearLayout) {

				LinearLayout linearLayout = (LinearLayout) childView;
				Bar bar = (Bar) linearLayout.getChildAt(0);
				TextView titleTxtView = (TextView) linearLayout.getChildAt(1);

				LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
				layerDrawable.mutate();

				ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

				GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();
				if (progressLayer != null) {
					progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor));
				}
				titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor));
			}
		}
	}
 
開發者ID:hadiidbouk,項目名稱:ChartProgressBar-Android,代碼行數:32,代碼來源:ChartProgressBar.java


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