本文整理汇总了Java中android.graphics.drawable.LevelListDrawable.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java LevelListDrawable.setBounds方法的具体用法?Java LevelListDrawable.setBounds怎么用?Java LevelListDrawable.setBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.LevelListDrawable
的用法示例。
在下文中一共展示了LevelListDrawable.setBounds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateColor
import android.graphics.drawable.LevelListDrawable; //导入方法依赖的package包/类
private void updateColor() {
Drawable leftDrawable = name.getCompoundDrawablesRelative()[0];
String domain = entity.getDomain();
if (leftDrawable != null && (domain.equals(LIGHT) || domain.equals(SWITCH))) {
if (!(leftDrawable instanceof LevelListDrawable)) {
LevelListDrawable levelListDrawable = new LevelListDrawable();
// Add states
levelListDrawable.addLevel(1, 1, leftDrawable);
BitmapDrawable enabledDrawable = (BitmapDrawable) leftDrawable.getConstantState().newDrawable().mutate();
enabledDrawable.setTintList(ColorStateList.valueOf(ContextCompat.getColor(name.getContext(), R.color.color_activated)));
levelListDrawable.addLevel(2, 2, enabledDrawable);
// Restore bounds
levelListDrawable.setBounds(0, 0, name.getResources().getDimensionPixelSize(R.dimen.icon_size), name.getResources().getDimensionPixelSize(R.dimen.icon_size));
// Set drawable
name.setCompoundDrawablesRelative(levelListDrawable, null, null, null);
leftDrawable = levelListDrawable;
}
leftDrawable.setLevel(entity.state.equals(HassUtils.getOnState(entity, false)) ? 1 : 2);
}
}
示例2: drawable
import android.graphics.drawable.LevelListDrawable; //导入方法依赖的package包/类
@NonNull
private static Drawable drawable(Context context) {
LevelListDrawable levels = new AppLevelListDrawable();
levels.addLevel(PLAY_ICON_LEVEL, PLAY_ICON_LEVEL, spinnerDrawable(context));
levels.addLevel(STOP_ICON_LEVEL, STOP_ICON_LEVEL, speakerDrawable(context));
int radius = getDimensionPixelSize(context, R.dimen.audio_url_span_loading_spinner_radius);
levels.setBounds(0, 0, radius * 2, radius * 2);
return levels;
}
示例3: getDrawable
import android.graphics.drawable.LevelListDrawable; //导入方法依赖的package包/类
@Override
public Drawable getDrawable(String source) {
Logger.d("URLImageParser", "source:" + source);
final LevelListDrawable mDrawable = new LevelListDrawable();
Drawable empty = new BitmapDrawable();
mDrawable.addLevel(0, 0, empty);
mDrawable.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
// get the actual source
ImageLoader.loadBitmapFromUrl(context, source, cookie, referer, new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(Bitmap bitmap) {
if (bitmap != null) {
Bitmap copy = bitmap.copy(Bitmap.Config.ARGB_8888, true);
Drawable drawable = new BitmapDrawable(context.getResources(), copy);
mDrawable.addLevel(1, 1, drawable);
mDrawable.setBounds(0, 0, copy.getWidth(), copy.getHeight());
mDrawable.setLevel(1);
new Handler(context.getMainLooper()).post(new Runnable() {
@Override
public void run() {
CharSequence t = textView.getText();
textView.setText(t);
}
});
}
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
}
});
// return reference to URLDrawable where I will change with actual image from
// the src tag
return mDrawable;
}
示例4: getDrawable
import android.graphics.drawable.LevelListDrawable; //导入方法依赖的package包/类
@Override
public Drawable getDrawable(String source) {
LevelListDrawable d = new LevelListDrawable();
Drawable empty = getResources().getDrawable(R.drawable.ic_launcher);
d.addLevel(0, 0, empty);
d.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
new LoadImage().execute(source, d);
return d;
}
示例5: getDrawable
import android.graphics.drawable.LevelListDrawable; //导入方法依赖的package包/类
@Override
public Drawable getDrawable(String source) {
LevelListDrawable drawable = new LevelListDrawable();
Drawable empty = ConversationActivity.this.getResources().getDrawable(R.drawable.ic_menu_refresh);
drawable.addLevel(0, 0, empty);
drawable.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
new LoadImage().execute(source, drawable, this.mTextView);
return drawable;
}