当前位置: 首页>>代码示例>>Java>>正文


Java LevelListDrawable.setBounds方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Maxr1998,项目名称:home-assistant-Android,代码行数:22,代码来源:SwitchViewHolder.java

示例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;
}
 
开发者ID:gnosygnu,项目名称:xowa_android,代码行数:10,代码来源:AudioUrlSpan.java

示例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;
}
 
开发者ID:PureDark,项目名称:H-Viewer,代码行数:37,代码来源:URLImageParser.java

示例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;
}
 
开发者ID:jungho-shin,项目名称:SIHSchool,代码行数:12,代码来源:SNoticeDetail.java

示例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;
}
 
开发者ID:mcilloni,项目名称:NerdzMessenger,代码行数:10,代码来源:ConversationActivity.java


注:本文中的android.graphics.drawable.LevelListDrawable.setBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。