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


Java LayerDrawable.getNumberOfLayers方法代碼示例

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


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

示例1: fromDrawable

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public static Drawable fromDrawable(Drawable drawable) {
  if (drawable != null) {
    if (drawable instanceof RoundedDrawable) {
      // just return if it's already a RoundedDrawable
      return drawable;
    } else if (drawable instanceof LayerDrawable) {
      LayerDrawable ld = (LayerDrawable) drawable;
      int num = ld.getNumberOfLayers();

      // loop through layers to and change to RoundedDrawables if possible
      for (int i = 0; i < num; i++) {
        Drawable d = ld.getDrawable(i);
        ld.setDrawableByLayerId(ld.getId(i), fromDrawable(d));
      }
      return ld;
    }

    // try to get a bitmap from the drawable and
    Bitmap bm = drawableToBitmap(drawable);
    if (bm != null) {
      return new RoundedDrawable(bm);
    }
  }
  return drawable;
}
 
開發者ID:weimin96,項目名稱:shareNote,代碼行數:26,代碼來源:RoundedDrawable.java

示例2: styleSeekBar

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void styleSeekBar() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    final Drawable progressDrawable = mSeekBar.getProgressDrawable();
    if (progressDrawable != null) {
      if (progressDrawable instanceof LayerDrawable) {
        LayerDrawable ld = (LayerDrawable) progressDrawable;
        int layers = ld.getNumberOfLayers();
        for (int i = 0; i < layers; i++) {
          ld.getDrawable(i).mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
        }
      } else {
        progressDrawable.mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
      }
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      final Drawable thumb = mSeekBar.getThumb();
      if (thumb != null) {
        thumb.mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
      }
    }
  }
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:24,代碼來源:SeekBarPreference.java

示例3: fromDrawable

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public static Drawable fromDrawable(Drawable drawable, Resources r) {
            if (drawable != null) {
                if (drawable instanceof SelectableRoundedCornerDrawable) {
                    return drawable;
                } else if (drawable instanceof LayerDrawable) {
                    LayerDrawable ld = (LayerDrawable) drawable;
                    final int num = ld.getNumberOfLayers();
                    for (int i = 0; i < num; i++) {
                        Drawable d = ld.getDrawable(i);
                        ld.setDrawableByLayerId(ld.getId(i), fromDrawable(d, r));
                    }
                    return ld;
                }

                Bitmap bm = drawableToBitmap(drawable);
                if (bm != null) {
                    return new SelectableRoundedCornerDrawable(bm, r);
                } else {
//                    Log.w(TAG, "Failed to create bitmap from drawable!");
                }
            }
            return drawable;
        }
 
開發者ID:zqHero,項目名稱:rongyunDemo,代碼行數:24,代碼來源:SelectableRoundedImageView.java

示例4: updateAttrs

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void updateAttrs(Drawable drawable) {
	if (drawable == null) {
		return;
	}

	if (drawable instanceof RoundedDrawable) {
		((RoundedDrawable) drawable).setScaleType(mScaleType).setCornerRadius(cornerRadius)
				.setBorderWidth(borderWidth).setBorderColor(borderColor).setOval(isOval);
	} else if (drawable instanceof LayerDrawable) {
		// loop through layers to and set drawable attrs
		LayerDrawable ld = ((LayerDrawable) drawable);
		for (int i = 0, layers = ld.getNumberOfLayers(); i < layers; i++) {
			updateAttrs(ld.getDrawable(i));
		}
	}
}
 
開發者ID:fahmisdk6,項目名稱:AvatarView,代碼行數:17,代碼來源:RoundedImageView.java

示例5: updateAttrs

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void updateAttrs(Drawable drawable)
{
	if (drawable == null)
	{
		return;
	}

	if (drawable instanceof RoundedDrawable)
	{
		((RoundedDrawable) drawable).setScaleType(mScaleType).setCornerRadius(cornerRadius)
				.setBorderWidth(borderWidth).setBorderColor(borderColor).setOval(isOval);
	}
	else if (drawable instanceof LayerDrawable)
	{
		// loop through layers to and set drawable attrs
		LayerDrawable ld = ((LayerDrawable) drawable);
		for (int i = 0, layers = ld.getNumberOfLayers(); i < layers; i++)
		{
			updateAttrs(ld.getDrawable(i));
		}
	}
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:23,代碼來源:RoundedImageView.java

示例6: updateAttrs

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void updateAttrs(Drawable drawable) {
    if (drawable != null) {
        if (drawable instanceof RoundedPagerDrawable) {
            ((RoundedPagerDrawable) drawable).setScaleType(this.mScaleType).setBorderWidth(this.mBorderWidth).setBorderColor(this.mBorderColor).setOval(this.mIsOval).setTileModeX(this.mTileModeX).setTileModeY(this.mTileModeY);
            if (this.mCornerRadii != null) {
                ((RoundedPagerDrawable) drawable).setCornerRadius(this.mCornerRadii[0], this.mCornerRadii[1], this.mCornerRadii[2], this.mCornerRadii[3]);
            }
            applyColorMod();
        } else if (drawable instanceof LayerDrawable) {
            LayerDrawable ld = (LayerDrawable) drawable;
            int layers = ld.getNumberOfLayers();
            for (int i = 0; i < layers; i++) {
                updateAttrs(ld.getDrawable(i));
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:18,代碼來源:RoundedImageView.java

示例7: fromDrawable

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
static Drawable fromDrawable(Drawable drawable, Resources r) {
    if (drawable != null) {
        if (drawable instanceof RoundedCornerDrawable) {
            return drawable;
        } else if (drawable instanceof LayerDrawable) {
            LayerDrawable ld = (LayerDrawable) drawable;
            final int num = ld.getNumberOfLayers();
            for (int i = 0; i < num; i++) {
                Drawable d = ld.getDrawable(i);
                ld.setDrawableByLayerId(ld.getId(i), fromDrawable(d, r));
            }
            return ld;
        }

        Bitmap bm = drawableToBitmap(drawable);
        if (bm != null) return new RoundedCornerDrawable(bm, r);
    }
    return drawable;
}
 
開發者ID:sciage,項目名稱:FinalProject,代碼行數:20,代碼來源:RoundedImageView.java

示例8: fromDrawable

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public static Drawable fromDrawable(Drawable drawable, Resources r) {
    if (drawable != null) {
        if (drawable instanceof SelectableRoundedCornerDrawable) {
            return drawable;
        } else if (drawable instanceof LayerDrawable) {
            LayerDrawable ld = (LayerDrawable) drawable;
            final int num = ld.getNumberOfLayers();
            for (int i = 0; i < num; i++) {
                Drawable d = ld.getDrawable(i);
                ld.setDrawableByLayerId(ld.getId(i), fromDrawable(d, r));
            }
            return ld;
        }

        Bitmap bm = drawableToBitmap1(drawable);
        if (bm != null) {
            return new SelectableRoundedCornerDrawable(bm, r);
        } else {
            MyLg.w(TAG, "Failed to create bitmap from drawable!");
        }
    }
    return drawable;
}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:24,代碼來源:SelectableRoundedImageView.java

示例9: updateAttrs

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void updateAttrs(Drawable drawable) {
    if (drawable != null) {
        if (drawable instanceof RoundedDrawable) {
            ((RoundedDrawable) drawable).setScaleType(this.mScaleType).setBorderWidth(this
                    .mBorderWidth).setBorderColor(this.mBorderColor).setOval(this.mIsOval)
                    .setTileModeX(this.mTileModeX).setTileModeY(this.mTileModeY);
            if (this.mCornerRadii != null) {
                ((RoundedDrawable) drawable).setCornerRadius(this.mCornerRadii[0], this
                        .mCornerRadii[1], this.mCornerRadii[2], this.mCornerRadii[3]);
            }
            applyColorMod();
        } else if (drawable instanceof LayerDrawable) {
            LayerDrawable ld = (LayerDrawable) drawable;
            int layers = ld.getNumberOfLayers();
            for (int i = 0; i < layers; i++) {
                updateAttrs(ld.getDrawable(i));
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:RoundedImageView.java

示例10: notifyDrawable

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
/**
 * Notifies the drawable that it's displayed state has changed.
 *
 * @param drawable
 * @param isDisplayed
 */
private static void notifyDrawable(Drawable drawable, final boolean isDisplayed) {
    if (drawable instanceof RecyclingBitmapDrawable) {
        // The drawable is a CountingBitmapDrawable, so notify it
        ((RecyclingBitmapDrawable) drawable).setIsDisplayed(isDisplayed);
    } else if (drawable instanceof LayerDrawable) {
        // The drawable is a LayerDrawable, so recurse on each layer
        LayerDrawable layerDrawable = (LayerDrawable) drawable;
        for (int i = 0, z = layerDrawable.getNumberOfLayers(); i < z; i++) {
            notifyDrawable(layerDrawable.getDrawable(i), isDisplayed);
        }
    }
}
 
開發者ID:PlutoArchitecture,項目名稱:Pluto-Android,代碼行數:19,代碼來源:RecyclingImageView.java

示例11: fixRepeatableDrawable

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
/**
 * Fix the repeatable background of a drawable.
 * This support both bitmap and layer drawables
 * @param d the drawable to fix.
 */
public static void fixRepeatableDrawable(Drawable d) {
    if(!needRepeatableFix()) {
        return;
    }
    if (d instanceof LayerDrawable) {
        LayerDrawable layer = (LayerDrawable) d;
        for (int i = 0; i < layer.getNumberOfLayers(); i++) {
            fixRepeatableDrawable(layer.getDrawable(i));
        }
    } else if (d instanceof BitmapDrawable) {
        fixRepeatableBitmapDrawable((BitmapDrawable) d);
    }

}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:20,代碼來源:Theme.java

示例12: updateAttrs

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void updateAttrs(Drawable drawable, ScaleType scaleType) {
  if (drawable == null) { return; }

  if (drawable instanceof RoundedDrawable) {
    ((RoundedDrawable) drawable)
            .setScaleType(scaleType)
            .setBorderWidth(mBorderWidth)
            .setBorderColor(mBorderColor)
            .setOval(mIsOval)
            .setTileModeX(mTileModeX)
            .setTileModeY(mTileModeY);

    if (mCornerRadii != null) {
      ((RoundedDrawable) drawable).setCornerRadius(
          mCornerRadii[Corner.TOP_LEFT],
          mCornerRadii[Corner.TOP_RIGHT],
          mCornerRadii[Corner.BOTTOM_RIGHT],
          mCornerRadii[Corner.BOTTOM_LEFT]);
    }

    applyColorMod();
  } else if (drawable instanceof LayerDrawable) {
    // loop through layers to and set drawable attrs
    LayerDrawable ld = ((LayerDrawable) drawable);
    for (int i = 0, layers = ld.getNumberOfLayers(); i < layers; i++) {
      updateAttrs(ld.getDrawable(i), scaleType);
    }
  }
}
 
開發者ID:weimin96,項目名稱:shareNote,代碼行數:30,代碼來源:RoundedImageView.java

示例13: fromDrawable

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
public static Drawable fromDrawable(Drawable drawable)
{
	if (drawable != null)
	{
		if (drawable instanceof RoundedDrawable)
		{
			// just return if it's already a RoundedDrawable
			return drawable;
		}
		else if (drawable instanceof LayerDrawable)
		{
			LayerDrawable ld = (LayerDrawable) drawable;
			int num = ld.getNumberOfLayers();

			// loop through layers to and change to RoundedDrawables if possible
			for (int i = 0; i < num; i++)
			{
				Drawable d = ld.getDrawable(i);
				ld.setDrawableByLayerId(ld.getId(i), fromDrawable(d));
			}
			return ld;
		}

		// try to get a bitmap from the drawable and
		Bitmap bm = drawableToBitmap(drawable);
		if (bm != null)
		{
			return new RoundedDrawable(bm);
		}
		else
		{
			Log.w(TAG, "Failed to create bitmap from drawable!");
		}
	}
	return drawable;
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:37,代碼來源:RoundedDrawable.java

示例14: updateAttrs

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
private void updateAttrs(Drawable drawable, ScaleType scaleType) {
    if (drawable == null) {
        return;
    }

    if (drawable instanceof RoundedDrawable) {
        ((RoundedDrawable) drawable)
                .setScaleType(scaleType)
                .setBorderWidth(mBorderWidth)
                .setBorderColor(mBorderColor)
                .setOval(mIsOval)
                .setTileModeX(mTileModeX)
                .setTileModeY(mTileModeY);

        if (mCornerRadii != null) {
            ((RoundedDrawable) drawable).setCornerRadius(
                    mCornerRadii[Corner.TOP_LEFT],
                    mCornerRadii[Corner.TOP_RIGHT],
                    mCornerRadii[Corner.BOTTOM_RIGHT],
                    mCornerRadii[Corner.BOTTOM_LEFT]);
        }

        applyColorMod();
    } else if (drawable instanceof LayerDrawable) {
        // loop through layers to and set drawable attrs
        LayerDrawable ld = ((LayerDrawable) drawable);
        for (int i = 0, layers = ld.getNumberOfLayers(); i < layers; i++) {
            updateAttrs(ld.getDrawable(i), scaleType);
        }
    }
}
 
開發者ID:jrvansuita,項目名稱:MaterialAbout,代碼行數:32,代碼來源:CircleImageView.java

示例15: tileify

import android.graphics.drawable.LayerDrawable; //導入方法依賴的package包/類
/**
 * Converts a drawable to a tiled version of itself. It will recursively
 * traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable, boolean clip) {

    if (drawable instanceof LayerDrawable) {
        LayerDrawable background = (LayerDrawable) drawable;
        final int N = background.getNumberOfLayers();
        Drawable[] outDrawables = new Drawable[N];

        for (int i = 0; i < N; i++) {
            int id = background.getId(i);
            outDrawables[i] = tileify(background.getDrawable(i),
                    (id == android.R.id.progress || id == android.R.id.secondaryProgress));
        }

        LayerDrawable newBg = new LayerDrawable(outDrawables);

        for (int i = 0; i < N; i++) {
            newBg.setId(i, background.getId(i));
        }

        return newBg;

    }/* else if (drawable instanceof StateListDrawable) {
        StateListDrawable in = (StateListDrawable) drawable;
        StateListDrawable out = new StateListDrawable();
        int numStates = in.getStateCount();
        for (int i = 0; i < numStates; i++) {
            out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
        }
        return out;

    }*/ else if (drawable instanceof BitmapDrawable) {
        final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
        if (mSampleTile == null) {
            mSampleTile = tileBitmap;
        }

        final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());

        final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
                Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        shapeDrawable.getPaint().setShader(bitmapShader);

        return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
                ClipDrawable.HORIZONTAL) : shapeDrawable;
    }

    return drawable;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:53,代碼來源:IcsProgressBar.java


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