项目:ArtOfAndroid
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.tv_transition).setonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
drawable.startTransition(3000);
}
});
ScaleDrawable scaleDrawable = (ScaleDrawable) findViewById(R.id.v_scale).getBackground();
scaleDrawable.setLevel(10); //Lever默认为0,无法显示。level范围为0~10000。level越大,显示的越大
ClipDrawable clipDrawable = (ClipDrawable) findViewById(R.id.v_clip).getBackground();
clipDrawable.setLevel(5000);
View vCustom = findViewById(R.id.v_custom);
CustomDrawable customDrawable = new CustomDrawable(getResources().getColor(R.color.colorAccent));
vCustom.setBackground(customDrawable);
}
项目:itsnat_droid
文件:Assert.java
public static void assertEquals(ScaleDrawable a,ScaleDrawable b)
{
assertEqualsDrawableWrapper(a,b);
assertEquals(a.isstateful(),b.isstateful());
Drawable.ConstantState a_state = a.getConstantState();
Drawable.ConstantState b_state = b.getConstantState();
Class classScaleState = TestUtil.resolveClass(ScaleDrawable.class.getName() + "$ScaleState");
assertEquals((Float) TestUtil.getField(a_state,classScaleState,"mScaleWidth"),(Float) TestUtil.getField(b_state,"mScaleWidth"));
assertEquals((Float) TestUtil.getField(a_state,"mScaleHeight"),"mScaleHeight"));
assertEquals((Integer) TestUtil.getField(a_state,"mGravity"),(Integer) TestUtil.getField(b_state,"mGravity"));
// android:drawable
if (Build.VERSION.SDK_INT < TestUtil.MARSHMALLOW) // 23
{
assertEquals((Drawable) TestUtil.getField(a_state,"mDrawable"),(Drawable) TestUtil.getField(b_state,"mDrawable"));
}
}
项目:android-art-res
文件:MainActivity.java
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// test transition
View v = findViewById(R.id.test_transition);
TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
drawable.startTransition(1000);
// test scale
View testScale = findViewById(R.id.test_scale);
ScaleDrawable testScaleDrawable = (ScaleDrawable) testScale.getBackground();
testScaleDrawable.setLevel(10);
// test clip
ImageView testClip = (ImageView) findViewById(R.id.test_clip);
ClipDrawable testClipDrawable = (ClipDrawable) testClip.getDrawable();
testClipDrawable.setLevel(8000);
// test custom drawable
View testCustomDrawable = findViewById(R.id.test_custom_drawable);
CustomDrawable customDrawable = new CustomDrawable(Color.parseColor("#0ac39e"));
testCustomDrawable.setBackgroundDrawable(customDrawable);
}
}
项目:android_ui
文件:SeekBarWidget.java
/**
* Applies current thumb tint from {@link Decorator#mTintInfo} to the current thumb drawable.
* <p>
* <b>Note</b>,that for post {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} this
* method does nothing.
*/
@SuppressWarnings("ConstantConditions")
private void applyThumbTint() {
this.ensureDecorator();
if (UiConfig.MATERIALIZED || mThumb == null || !mDecorator.hasTintInfo()) {
return;
}
final Drawable thumb = mThumb instanceof ScaleDrawable ? ((ScaleDrawable) mThumb).getDrawable() : mThumb;
final SeekBarTintInfo tintInfo = mDecorator.getTintInfo();
if ((!tintInfo.hasTintList && !tintInfo.hasTintMode)) {
return;
}
final boolean isTintDrawable = thumb instanceof TintDrawable;
final TintDrawable tintDrawable = isTintDrawable ? (TintDrawable) thumb : new TintDrawable(thumb);
if (tintInfo.hasTintList) {
tintDrawable.setTintList(tintInfo.tintList);
}
if (tintInfo.hasTintMode) {
tintDrawable.setTintMode(tintInfo.tintMode);
}
if (tintDrawable.isstateful()) {
tintDrawable.setState(getDrawableState());
}
if (isTintDrawable) {
return;
}
final int thumbOffset = getThumbOffset();
this.mThumb = mDecorator.hasPrivateFlag(PFLAG_disCRETE) ?
mAnimations.makeThumbScaleable(tintDrawable,Gravity.CENTER) :
tintDrawable;
super.setThumb(mThumb);
tintDrawable.attachCallback();
setThumbOffset(thumbOffset);
}
项目:android_ui
文件:SeekBarWidget.java
/**
* Updates a scale level of the thumb's drawable.
*
* @param scale The scale value from the range {@code [0.0,1.0]}.
*/
@SuppressWarnings("Range")
void setThumbScale(float scale) {
if (view.mThumb instanceof ScaleDrawable) {
final int scaleLevel = Math.round(scale * MAX_LEVEL);
view.mThumb.setLevel(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN ?
scaleLevel :
// Correct scale level for pre JELLY_BEAN Android versions.
// scaleLevel(10000) = scale(1.0) [expected scale(1.0)]
// scaleLevel(5000) = scale(0.0) [expected scale(0.5)]
// scaleLevel(0) = scale(1.0) [expected scale(0.0)]
scaleLevel + (int) ((10000 - scaleLevel) / 10000f * 5000)
);
}
}
项目:Typewriter
文件:TypewriterRefreshDrawable.java
private void setupDrawables() {
parts = new ArrayList<>();
parts.add(ContextCompat.getDrawable(getContext(),R.drawable.carriage_part1));
parts.add(ContextCompat.getDrawable(getContext(),R.drawable.carriage_part2));
parts.add(ContextCompat.getDrawable(getContext(),R.drawable.carriage_part3));
carriageOffset = (int) getContext().getResources().getDimension(R.dimen.carriage_offset);
pageOffset = (int) getContext().getResources().getDimension(R.dimen.page_offset);
offset = (int) getContext().getResources().getDimension(R.dimen.offset);
button = ContextCompat.getDrawable(getContext(),R.drawable.button);
buttonpressed = ContextCompat.getDrawable(getContext(),R.drawable.button_pressed);
page = new ScaleDrawable(ContextCompat.getDrawable(getContext(),R.drawable.page),TOP,-1,1);
page.setLevel(10000);
pageBack =
new ScaleDrawable(ContextCompat.getDrawable(getContext(),R.drawable.page_revers),1);
pageBack.setLevel(0);
keyboard = ContextCompat.getDrawable(getContext(),R.drawable.keyboard_bg);
typewriter = ContextCompat.getDrawable(getContext(),R.drawable.machine);
space = ContextCompat.getDrawable(getContext(),R.drawable.space);
spacepressed = ContextCompat.getDrawable(getContext(),R.drawable.space_pressed);
letter = ContextCompat.getDrawable(getContext(),R.drawable.letter);
}
/**
* Some drawable implementations have problems with mutation. This method returns false if
* there is a kNown issue in the given drawable's implementation.
*/
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
return false;
} else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
// GradientDrawable has a bug pre-ICS which results in mutate() resulting
// in loss of color
return false;
} else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
return false;
}
if (drawable instanceof DrawableContainer) {
// If we have a DrawableContainer,let's traverse its child array
final Drawable.ConstantState state = drawable.getConstantState();
if (state instanceof DrawableContainer.DrawableContainerState) {
final DrawableContainer.DrawableContainerState containerState =
(DrawableContainer.DrawableContainerState) state;
for (final Drawable child : containerState.getChildren()) {
if (!canSafelyMutateDrawable(child)) {
return false;
}
}
}
} else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
return canSafelyMutateDrawable(
((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
.getWrappedDrawable());
} /*else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
return canSafelyMutateDrawable(
((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
.getWrappedDrawable());
}*/ else if (drawable instanceof ScaleDrawable) {
return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
}
return true;
}
项目:mvvm-template
文件:FontTextView.java
public void setEventsIcon(@DrawableRes int drawableRes) {
Drawable drawable = ContextCompat.getDrawable(getContext(),drawableRes);
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
drawable.setBounds(0,width / 2,height / 2);
ScaleDrawable sd = new ScaleDrawable(drawable,Gravity.CENTER,0.6f,0.6f);
sd.setLevel(8000);
ViewHelper.tintDrawable(drawable,ViewHelper.getTertiaryTextColor(getContext()));
setCompoundDrawablesWithIntrinsicBounds(sd,null,null);
}
项目:MeetMusic
文件:PlayActivity.java
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();
}
}
/**
* Some drawable implementations have problems with mutation. This method returns false if
* there is a kNown issue in the given drawable's implementation.
*/
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
return false;
} else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
// GradientDrawable has a bug pre-ICS which results in mutate() resulting
// in loss of color
return false;
} else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
return false;
}
if (drawable instanceof DrawableContainer) {
// If we have a DrawableContainer,let's traverse it's child array
final Drawable.ConstantState state = drawable.getConstantState();
if (state instanceof DrawableContainer.DrawableContainerState) {
final DrawableContainer.DrawableContainerState containerState =
(DrawableContainer.DrawableContainerState) state;
for (final Drawable child : containerState.getChildren()) {
if (!canSafelyMutateDrawable(child)) {
return false;
}
}
}
} else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
return canSafelyMutateDrawable(
((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
.getWrappedDrawable());
} else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
return canSafelyMutateDrawable(
((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
.getWrappedDrawable());
} else if (drawable instanceof ScaleDrawable) {
return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
}
return true;
}
项目:solved-hacking-problem
文件:bt.java
public static boolean m2634b(Drawable drawable) {
if (drawable instanceof LayerDrawable) {
return VERSION.SDK_INT >= 16;
} else if (drawable instanceof InsetDrawable) {
return VERSION.SDK_INT >= 14;
} else {
if (drawable instanceof StateListDrawable) {
return VERSION.SDK_INT >= 8;
} else {
if (drawable instanceof GradientDrawable) {
return VERSION.SDK_INT >= 14;
} else {
if (!(drawable instanceof DrawableContainer)) {
return drawable instanceof C0063q ? m2634b(((C0063q) drawable).m469a()) : drawable instanceof C0244a ? m2634b(((C0244a) drawable).m1984a()) : drawable instanceof ScaleDrawable ? m2634b(((ScaleDrawable) drawable).getDrawable()) : true;
} else {
ConstantState constantState = drawable.getConstantState();
if (!(constantState instanceof DrawableContainerState)) {
return true;
}
for (Drawable b : ((DrawableContainerState) constantState).getChildren()) {
if (!m2634b(b)) {
return false;
}
}
return true;
}
}
}
}
}
项目:droidddle
文件:SeekBarCompat.java
/***
* Method called from APIs below 21 to setup Progress Color
*/
private void setupProgressColor() {
//load up the drawable and apply color
LayerDrawable ld = (LayerDrawable) getProgressDrawable();
ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
shape.setColorFilter(mProgressColor,PorterDuff.Mode.SRC_IN);
//set the background to transparent
NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
ninePatchDrawable.setColorFilter(Color.TRANSPARENT,PorterDuff.Mode.SRC_IN);
}
项目:droidddle
文件:SeekBarCompat.java
@Override
public void setEnabled(final boolean enabled) {
mIsEnabled = enabled;
triggerMethodonceViewIsdisplayed(this,new Callable<Void>() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public Void call() throws Exception {
if (!lollipopAndAbove()) {
gradientDrawable = new GradientDrawable();
gradientDrawable.setShape(GradientDrawable.oval);
gradientDrawable.setSize(mOriginalThumbHeight / 3,mOriginalThumbHeight / 3);
gradientDrawable.setColor(mIsEnabled ? mThumbColor : Color.LTGRAY);
gradientDrawable.setDither(true);
gradientDrawable.setAlpha(mThumbAlpha);
setThumb(gradientDrawable);
//load up the drawable and apply color
LayerDrawable ld = (LayerDrawable) getProgressDrawable();
ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
shape.setColorFilter(mIsEnabled ? mProgressColor : Color.LTGRAY,PorterDuff.Mode.SRC_IN);
//set the background to transparent
NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
ninePatchDrawable.setColorFilter(Color.TRANSPARENT,PorterDuff.Mode.SRC_IN);
//background
//load up the drawable and apply color
SeekBarBackgroundDrawable seekBarBackgroundDrawable = new SeekBarBackgroundDrawable(getContext(),mIsEnabled ? mProgressBackgroundColor : Color.LTGRAY,mActualBackgroundColor,getPaddingLeft(),getPaddingRight());
if (belowJellybean())
setBackgroundDrawable(seekBarBackgroundDrawable);
else
setBackground(seekBarBackgroundDrawable);
}
SeekBarCompat.super.setEnabled(enabled);
return null;
}
});
}
项目:crofis-android-uikit
文件:SeekBarCompat.java
/***
* Method called from APIs below 21 to setup Progress Color
*/
private void setupProgressColor() {
try {
//load up the drawable and apply color
LayerDrawable ld = (LayerDrawable) getProgressDrawable();
ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
shape.setColorFilter(mProgressColor,PorterDuff.Mode.SRC_IN);
//set the background to transparent
NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
ninePatchDrawable.setColorFilter(Color.TRANSPARENT,PorterDuff.Mode.SRC_IN);
} catch (NullPointerException e) {
//Todo: Handle exception
}
}
项目:crofis-android-uikit
文件:SeekBarCompat.java
/***
* Enables or disables the whole seekBar!
*
* @param enabled
*/
@Override
public void setEnabled(final boolean enabled) {
mIsEnabled = enabled;
triggerMethodonceViewIsdisplayed(this,getPaddingRight());
if (belowJellybean())
setBackgroundDrawable(seekBarBackgroundDrawable);
else
setBackground(seekBarBackgroundDrawable);
}
SeekBarCompat.super.setEnabled(enabled);
return null;
}
});
}
项目:itsnat_droid
文件:ClassDescScaleDrawable.java
@Override
public boolean isAttributeIgnored(ScaleDrawable resource,String namespaceURI,String name)
{
if (super.isAttributeIgnored(resource,namespaceURI,name))
return true;
if (NamespaceUtil.XMLNS_ANDROID.equals(namespaceURI))
{
// Se usan en tiempo de construcción
return ("drawable".equals(name) || "scaleGravity".equals(name) || "scaleHeight".equals(name) || "scaleWidth".equals(name));
}
return false;
}
项目:Android_Skin_2.0
文件:NumberProgressBar.java
private Drawable tileifyProgressDrawable(Drawable wrapped) {
if (wrapped instanceof LayerDrawable) {
LayerDrawable drawable = (LayerDrawable) wrapped;
final int N = drawable.getNumberOfLayers();
Drawable[] outDrawables = new Drawable[N];
for (int i = 0; i < N; i++) {
final int id = drawable.getId(i);
Drawable childDrawable = drawable.getDrawable(i);
if (id == android.R.id.background) {
outDrawables[i] = new NumberBGDrawable(childDrawable);
} else if (id == android.R.id.progress) {
if (childDrawable instanceof ScaleDrawable) {
outDrawables[i] = tileifyScaleDrawable((ScaleDrawable) childDrawable);
} else if (childDrawable instanceof ClipDrawable) {
outDrawables[i] = tileifyClipDrawable((ClipDrawable) childDrawable);
} else {
outDrawables[i] = childDrawable;
}
} else {
outDrawables[i] = childDrawable;
}
}
LayerDrawable newDrawable = new NumberLayerDrawable(outDrawables);
return newDrawable;
}
return wrapped;
}
项目:android_ui
文件:SeekBarWidget.java
/**
* Applies current discrete indicator tint from {@link Decorator#mTintInfo} to the current discrete
* indicator's drawable.
*/
@SuppressLint("NewApi")
@SuppressWarnings("ConstantConditions")
private void applydiscreteIndicatorTint() {
this.ensureDecorator();
if (mdiscreteIndicator == null || !mDecorator.hasTintInfo()) {
return;
}
final Drawable indicator = mdiscreteIndicator instanceof ScaleDrawable ? ((ScaleDrawable) mdiscreteIndicator).getDrawable() : mdiscreteIndicator;
final SeekBarTintInfo tintInfo = mDecorator.getTintInfo();
if ((!tintInfo.hasdiscreteIndicatorTintList && !tintInfo.hasdiscreteIndicatorTintMode)) {
return;
}
if (UiConfig.MATERIALIZED) {
this.mdiscreteIndicator = mdiscreteIndicator.mutate();
if (tintInfo.hasdiscreteIndicatorTintList) {
mdiscreteIndicator.setTintList(tintInfo.discreteIndicatorTintList);
}
if (tintInfo.hasdiscreteIndicatorTintMode) {
mdiscreteIndicator.setTintMode(tintInfo.discreteIndicatorTintMode);
}
if (mdiscreteIndicator.isstateful()) {
mdiscreteIndicator.setState(getDrawableState());
}
return;
}
final boolean isTintDrawable = indicator instanceof TintDrawable;
final TintDrawable tintDrawable = isTintDrawable ? (TintDrawable) indicator : new TintDrawable(indicator);
if (tintInfo.hasdiscreteIndicatorTintList) {
tintDrawable.setTintList(tintInfo.discreteIndicatorTintList);
}
if (tintInfo.hasdiscreteIndicatorTintMode) {
tintDrawable.setTintMode(tintInfo.discreteIndicatorTintMode);
}
if (isTintDrawable) {
return;
}
this.mdiscreteIndicator = mDecorator.hasPrivateFlag(PFLAG_disCRETE) ?
mAnimations.makediscreteIndicatorScaleable(tintDrawable,Gravity.BottOM | Gravity.CENTER_HORIZONTAL) :
tintDrawable;
mdiscreteIndicator.setCallback(this);
updatediscreteIndicatorState(getDrawableState(),false);
}
项目:ChartProgressBar-Android
文件:ChartProgressBar.java
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));
}
}
}
}
项目:ChartProgressBar-Android
文件:ChartProgressBar.java
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));
}
}
}
}
}
}
项目:ChartProgressBar-Android
文件:ChartProgressBar.java
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,mBarTitleColor));
else
titleTxtView.setTextColor(ContextCompat.getColor(mContext,android.R.color.darker_gray));
}
}
}
}
}
}
项目:GND_Control
文件:Home.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Resources res = getResources();
TabHost tabHost = getTabHost();
// Profiles tab
ScaleDrawable sd = new ScaleDrawable(res.getDrawable(R.drawable.quadiconlow),10f,10f);
Intent intentwindows = new Intent().setClass(this,Profile.class);
TabHost.TabSpec tabSpecWindows = tabHost
.newTabSpec("Windows")
.setIndicator("",sd.getDrawable())
.setContent(intentwindows);
ScaleDrawable sd2 = new ScaleDrawable(res.getDrawable(R.drawable.routeslow),10f);
Intent intentwindows2 = new Intent().setClass(this,Profile.class);
TabHost.TabSpec tabSpecWindows2 = tabHost
.newTabSpec("Windows")
.setIndicator("",sd2.getDrawable())
.setContent(intentwindows);
ScaleDrawable sd3 = new ScaleDrawable(res.getDrawable(R.drawable.waveslow),10f);
Intent intentwindows3 = new Intent().setClass(this,Profile.class);
TabHost.TabSpec tabSpecWindows3 = tabHost
.newTabSpec("Windows")
.setIndicator("",sd3.getDrawable())
.setContent(intentwindows);
ScaleDrawable sd4 = new ScaleDrawable(res.getDrawable(R.drawable.controllow),10f);
Intent intentwindows4 = new Intent().setClass(this,Profile.class);
TabHost.TabSpec tabSpecWindows4 = tabHost
.newTabSpec("Windows")
.setIndicator("",sd4.getDrawable())
.setContent(intentwindows);
/*ScaleDrawable sd5 = new ScaleDrawable(res.getDrawable(R.drawable.aboutlow),10f);
Intent intentwindows5 = new Intent().setClass(this,Profile.class);
TabHost.TabSpec tabSpecWindows5 = tabHost
.newTabSpec("Windows")
.setIndicator("",sd5.getDrawable())
.setContent(intentwindows);
ScaleDrawable sd6 = new ScaleDrawable(res.getDrawable(R.drawable.donatelow),10f);
Intent intentwindows6 = new Intent().setClass(this,Profile.class);
TabHost.TabSpec tabSpecWindows6 = tabHost
.newTabSpec("Windows")
.setIndicator("",sd4.getDrawable())
.setContent(intentwindows);*/
// add all tabs
tabHost.addTab(tabSpecWindows);
tabHost.addTab(tabSpecWindows2);
tabHost.addTab(tabSpecWindows3);
tabHost.addTab(tabSpecWindows4);
//tabHost.addTab(tabSpecWindows5);
//tabHost.addTab(tabSpecWindows6);
}
项目:RTP-API-Gradle-Maven-android-file-Selector-Java
文件:PreFileSelectorActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pre_file_selector);
toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setTitleTextColor(getResources().getColor(R.color.fs_colorAccent));
getSupportActionBar().setdisplayShowTitleEnabled(false);
}
Drawable drawableMyFiles = getResources().getDrawable(R.drawable.my_files_icon_sequencing_com_color);
drawableMyFiles.setBounds(0,(int)(drawableMyFiles.getIntrinsicWidth()*0.65),(int)(drawableMyFiles.getIntrinsicHeight()*0.65));
ScaleDrawable sdMyFiles = new ScaleDrawable(drawableMyFiles,50,50);
Drawable drawableSampleFiles = getResources().getDrawable(R.drawable.sample_files_icon_sequencing_com_blue);
drawableSampleFiles.setBounds(0,(int) (drawableSampleFiles.getIntrinsicWidth() * 0.6),(int) (drawableSampleFiles.getIntrinsicHeight() * 0.6));
ScaleDrawable sdSampleFiles = new ScaleDrawable(drawableSampleFiles,50);
videoView = (CVideoView) findViewById(R.id.video_view);
btnMyFiles = (Button) findViewById(R.id.btnMyFiles);
btnMyFiles.setCompoundDrawables(sdMyFiles.getDrawable(),null);
tvTextTitle = (TextView) findViewById(R.id.tvTextTitle);
tvText = (TextView) findViewById(R.id.tvText);
btnSampleFiles = (Button) findViewById(R.id.btnSampleFiles);
btnSampleFiles.setCompoundDrawables(sdSampleFiles.getDrawable(),null);
btnMyFiles.setonClickListener(this);
btnSampleFiles.setonClickListener(this);
fabInfo = (FloatingActionButton) findViewById(R.id.fab);
fabInfo.setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(toolTipView != null){
toolTipView.remove();
toolTipView = null;
} else {
displayInfo();
}
}
});
fileSelectorIntent = new Intent(getBaseContext(),FileSelectorActivity.class);
fileSelectorIntent.putExtra("serverResponse",getIntent().getStringExtra("serverResponse"));
fileSelectorIntent.putExtra("fileId",getIntent().getStringExtra("fileId"));
fileSelectorIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
项目:itsnat_droid
文件:ClassDescScaleDrawable.java
public ClassDescScaleDrawable(ClassDescDrawableMgr classMgr,ClassDescElementDrawableBased<? super ScaleDrawable> parent)
{
super(classMgr,"scale",parent);
}
项目:itsnat_droid
文件:ClassDescScaleDrawable.java
@Override
public Class<ScaleDrawable> getDrawableOrElementDrawableClass()
{
return ScaleDrawable.class;
}
项目:itsnat_droid
文件:Assert.java
public static void assertEquals(Drawable a,Drawable b)
{
if (!a.getClass().equals(b.getClass())) throw new ItsNatDroidException("Not equal: \"" + a + "\" - \"" + b + "\"");
if (a instanceof AnimationDrawable)
{
assertEquals((AnimationDrawable) a,(AnimationDrawable) b);
}
else if (a instanceof BitmapDrawable)
{
assertEquals((BitmapDrawable)a,(BitmapDrawable)b);
}
else if (a instanceof ClipDrawable)
{
assertEquals((ClipDrawable)a,(ClipDrawable)b);
}
else if (a instanceof ColorDrawable)
{
assertEquals(((ColorDrawable) a).getColor(),((ColorDrawable) b).getColor());
}
else if (a instanceof GradientDrawable)
{
assertEquals((GradientDrawable)a,(GradientDrawable)b);
}
else if (a instanceof InsetDrawable)
{
assertEquals((InsetDrawable)a,(InsetDrawable)b);
}
else if (a instanceof LayerDrawable)
{
assertEquals((LayerDrawable)a,(LayerDrawable)b);
}
else if (a instanceof LevelListDrawable)
{
assertEquals((LevelListDrawable)a,(LevelListDrawable)b);
}
else if (a instanceof NinePatchDrawable)
{
assertEquals((NinePatchDrawable)a,(NinePatchDrawable)b);
}
else if (a instanceof RotateDrawable)
{
assertEquals((RotateDrawable)a,(RotateDrawable)b);
}
else if (a instanceof ScaleDrawable)
{
assertEquals((ScaleDrawable)a,(ScaleDrawable)b);
}
else if (a instanceof StateListDrawable)
{
assertEquals((StateListDrawable)a,(StateListDrawable)b);
}
else if (a instanceof TransitionDrawable)
{
assertEquals((TransitionDrawable)a,(TransitionDrawable)b);
}
else
throw new ItsNatDroidException("Cannot test drawable " + a);
}
项目:android_ui
文件:SeekBarWidget.java
/**
* Returns the current discrete indicator's drawable.
* <p>
* <b>Note,that on pre {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android versions
* this method will return an instance of {@link TintDrawable TintDrawable} if tint has been applied
* via {@link #setdiscreteIndicatorTintList(ColorStateList)}.</b>
* <p>
* The original wrapped indicator drawable can be obtained via {@link TintDrawable#getDrawable()}.
*
* @return discrete indicator's drawable.
* @see #setdiscreteIndicator(android.graphics.drawable.Drawable)
*/
@Nullable
public Drawable getdiscreteIndicator() {
if (mdiscreteIndicator instanceof ScaleDrawable)
return ((ScaleDrawable) mdiscreteIndicator).getDrawable();
else
return mdiscreteIndicator;
}
项目:android_ui
文件:SeekBarWidget.java
/**
* Wraps the given <var>drawable</var> into instance of {@link ScaleDrawable} if it is valid
* and not ScaleDrawable yet.
*
* @param drawable The drawable to wrap and make scaleable.
* @param gravity The gravity determining a pivot along which can be the given drawable scaled.
* @return Instance of ScaleDrawable with the specified drawable wrapped or {@code null}
* if the given drawable was also {@code null}.
*/
static Drawable makeDrawableScaleable(Drawable drawable,int gravity) {
if (drawable == null || drawable instanceof ScaleDrawable) return drawable;
final ScaleDrawable scaleDrawable = new ScaleDrawable(drawable,gravity,1f,1f);
scaleDrawable.setLevel(MAX_LEVEL);
return scaleDrawable;
}
项目:ChartProgressBar-Android
文件:ChartProgressBar.java
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));
}
}
}
项目:ActionBarProgress
文件:MaterialProgressDrawable.java
public static MaterialProgressDrawable create(@NonNull Context context) {
Drawable[] layers = new Drawable[3];
layers[0] = new ColorDrawable(ThemeUtils.getdisabledThemeAttrColor(context,R.attr.colorControlnormal));
Drawable secondaryProgress = new ColorDrawable(ThemeUtils.getdisabledThemeAttrColor(context,R.attr.colorControlActivated));
layers[1] = new ScaleDrawable(secondaryProgress,Gravity.START,-1f);
Drawable progress = new ColorDrawable(ThemeUtils.getThemeAttrColor(context,R.attr.colorControlActivated));
layers[2] = new ScaleDrawable(progress,-1f);
return new MaterialProgressDrawable(layers);
}
项目:itsnat_droid
文件:ClassDescScaleDrawable.java
@Override
public ElementDrawableChildRoot createElementDrawableChildRoot(DOMElemDrawable rootElem,AttrDrawableContext attrCtx)
{
ElementDrawableChildRoot elementDrawableRoot = new ElementDrawableChildRoot();
XMLInflaterContext xmlInflaterContext = attrCtx.getXMLInflaterContext();
XMLInflaterDrawable xmlInflaterDrawable = attrCtx.getXMLInflaterDrawable();
xmlInflaterDrawable.processChildElements(rootElem,elementDrawableRoot,attrCtx);
ArrayList<ElementDrawableChildBase> childList = elementDrawableRoot.getElementDrawableChildList();
Drawable childDrawable = getDrawableChild("drawable",rootElem,xmlInflaterContext,childList);
XMLInflaterRegistry xmlInflaterRegistry = classMgr.getXMLInflaterRegistry();
DOMAttr attrGravity = rootElem.getDOMAttribute(NamespaceUtil.XMLNS_ANDROID,"scaleGravity");
int gravity = attrGravity != null ? AttrDesc.parseMultipleName(attrGravity.getValue(),GravityUtil.nameValueMap) : Gravity.LEFT; // Valor concreto no puede ser un recurso
DOMAttr attrScaleHeight = rootElem.getDOMAttribute(NamespaceUtil.XMLNS_ANDROID,"scaleHeight");
float scaleHeight = attrScaleHeight != null ? getPercent(xmlInflaterRegistry.getDimensionorString(attrScaleHeight.getResourceDesc(),xmlInflaterContext)) : -1; // Se puede poner en un values/ como un <string> o como un <dimen> (aunque luego se procese como un String)
DOMAttr attrScaleWidth = rootElem.getDOMAttribute(NamespaceUtil.XMLNS_ANDROID,"scaleWidth");
float scaleWidth = attrScaleWidth != null ? getPercent(xmlInflaterRegistry.getDimensionorString(attrScaleWidth.getResourceDesc(),xmlInflaterContext)) : -1;
ScaleDrawable drawable = new ScaleDrawable(childDrawable,scaleWidth,scaleHeight);
setCallback(childDrawable,drawable);
elementDrawableRoot.setDrawable(drawable);
return elementDrawableRoot;
}
项目:android_ui
文件:SeekBarWidget.java
/**
* <b>Note,that on pre {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android versions
* this method will return an instance of {@link TintDrawable TintDrawable} if tint has been applied
* via {@link #setThumbTintList(ColorStateList)}.</b>
* <p>
* The original wrapped drawable can be obtained via {@link TintDrawable#getDrawable()}.
*/
@Override
public Drawable getThumb() {
if (mThumb instanceof ScaleDrawable) return ((ScaleDrawable) mThumb).getDrawable();
return mThumb;
}
项目:android_ui
文件:SeekBarWidget.java
/**
* Updates a scale level of the given <var>drawable</var> according to the specified scale
* value.
*
* @param drawable The drawable of which scale level to update.
* @param scale The scale value from the range {@code [0.0,1.0]}.
*/
private void updateDrawableScale(Drawable drawable,float scale) {
if (drawable instanceof ScaleDrawable) drawable.setLevel(Math.round(scale * MAX_LEVEL));
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。