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


Java ImageView.setBackgroundResource方法代码示例

本文整理汇总了Java中android.widget.ImageView.setBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setBackgroundResource方法的具体用法?Java ImageView.setBackgroundResource怎么用?Java ImageView.setBackgroundResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.setBackgroundResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void convert(BaseViewHolder helper, NoteFolder item) {
    helper.setText(R.id.tv_folder_list_title, item.getFolderName())
            .setText(R.id.tv_folder_list_count, item.getNoteCount() + "");


    RelativeLayout rlItem=helper.getView(R.id.rl_folder_root);
    TextView tvTitle=helper.getView(R.id.tv_folder_list_title);
    TextView tvCount=helper.getView(R.id.tv_folder_list_count);
    ImageView ivIcon=helper.getView(R.id.iv_folder_list_ic);

    if(Constans.currentFolder == helper.getLayoutPosition()-getHeaderLayoutCount()){
        rlItem.setSelected(true);
        tvTitle.setTextColor(ThemeUtils.getColorPrimary(mContext));
        tvCount.setTextColor(ThemeUtils.getColorPrimary(mContext));
        ivIcon.setBackground(MyDrawable.getIcFolderSelectedDrawable( ThemeUtils.getColorPrimary(mContext)));
    } else {
        rlItem.setSelected(false);
        tvTitle.setTextColor(MainApplication.getContext().getResources().getColor(R.color.colorBlackAlpha87));
        tvCount.setTextColor(MainApplication.getContext().getResources().getColor(R.color.colorBlackAlpha54));
        ivIcon.setBackgroundResource(R.drawable.ic_folder_un_selected);
    }
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:24,代码来源:RvNoteFolderAdapter.java

示例2: loadViews

import android.widget.ImageView; //导入方法依赖的package包/类
public void loadViews() {
	titles = new String[mMapBitmaps.size()];
	mPics = new ArrayList<ImageView>();
	mDots = new ArrayList<View>();
	int i=0;
	for(String key:mMapBitmaps.keySet()){
		titles[i++] = key;
		ImageView iv1 = new ImageView(StationDetailAty.this);
		iv1.setImageBitmap(mMapBitmaps.get(key));
		iv1.setScaleType(ScaleType.CENTER_CROP);
		iv1.setOnClickListener(new MyOnClickListener(i));
		mPics.add(iv1);
		
		ImageView iv2 = new ImageView(StationDetailAty.this);
		iv2.setBackgroundResource(R.drawable.dot_normal);
		mDots.add(iv2);
	}
	tvTitle.setText(titles[0]);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:20,代码来源:StationDetailAty.java

示例3: initIconView

import android.widget.ImageView; //导入方法依赖的package包/类
private View initIconView() {
    FrameLayout contentView = new FrameLayout(LiteIconActivity.this);
    int gridW = (int) (displayMetrics.density * GRID_W_IN_DP);
    int gridH = (int) (displayMetrics.density * GRID_H_IN_DP);
    ViewGroup.LayoutParams lpCv = new ViewGroup.LayoutParams(gridW, gridH);
    contentView.setLayoutParams(lpCv);

    ImageView ivIcon = new ImageView(LiteIconActivity.this);
    ivIcon.setTag("iv");
    ivIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ivIcon.setClickable(true);
    ivIcon.setBackgroundResource(getClickBg());
    int iconSize = (int) (displayMetrics.density * ICON_SIZE_IN_DP);
    FrameLayout.LayoutParams lpIv = new FrameLayout.LayoutParams(iconSize, iconSize);
    lpIv.gravity = Gravity.CENTER;
    ivIcon.setLayoutParams(lpIv);
    contentView.addView(ivIcon);

    return contentView;
}
 
开发者ID:by-syk,项目名称:NanoIconPackLite,代码行数:21,代码来源:LiteIconActivity.java

示例4: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle(title);
    infoText = (TextView) findViewById(R.id.infoView);
    imgView = (ImageView) findViewById(R.id.cardbg);
    imgView.setBackgroundResource(R.drawable.myanim);
    _animation = (AnimationDrawable) imgView.getBackground();
    _animation.setOneShot(false);
    uiHandler = new MyHandler(this);

    mBluetoothReader = new BluetoothReader();
    mBluetoothReader.setOnReaderStateListener(new BluetoothReader.OnReaderStateListener() {
        @Override
        public void onReaderStateChange(String readerName, int readerState) {
            if (readerName.isEmpty() == false) {
                uiHandler.obtainMessage(READER_MESSAGE, readerState, -1, readerName).sendToTarget();
            }
        }
    });

    View scan = findViewById(R.id.btScan);
    scan.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            infoText.setText("Select bluetooth reader for connect...");
            Intent serverIntent = new Intent(TestActivity3.this, DeviceListActivity.class);
            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
        }
    });
}
 
开发者ID:NaOHAndroid,项目名称:Logistics-guard,代码行数:33,代码来源:TestActivity3.java

示例5: startEditMode

import android.widget.ImageView; //导入方法依赖的package包/类
private void startEditMode(RecyclerView parent) {
    this.isEditMode = true;
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View view = parent.getChildAt(i);
        if (view != null) {
            ImageView imgEdit = (ImageView) view.findViewById(R.id.edit_tip);
            RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.item_group_id);
            if (layout != null) {
                layout.setBackgroundResource(R.drawable.channel_wall_item_selecter_bg);
            }
            if (imgEdit != null) {
                if (((Integer) imgEdit.getTag()).intValue() == 0) {
                    imgEdit.setBackgroundResource(2130837812);
                } else {
                    imgEdit.setBackgroundResource(2130837811);
                }
                imgEdit.setVisibility(0);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:ChannelFragmentAdapter.java

示例6: getView

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
    ImageView img = new ImageView(context);
    img.setBackgroundResource(R.color.white);
    img.setPadding(2, 2, 2, 2);
    img.setScaleType(ImageView.ScaleType.CENTER_CROP);

    int width = ScreenUtils.getScreenWidth(context) - DensityUtils.dp2px(context, 117);// 获取屏幕宽度
    int height = width = width / 4;// 对当前的列数进行设置imgView的宽度
    img.setLayoutParams(new AbsListView.LayoutParams(width, height));

    Glide
            .with(context)
            .load(Constants.PICTURE_URL + list.get(position))
            .override(width, height)
            .skipMemoryCache(true)
            .centerCrop()
            .crossFade()
            .placeholder(R.drawable.img_loading)
            .error(R.drawable.img_error)
            .into(img);

    return img;
}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:25,代码来源:SmallBitmapGridViewAdapter.java

示例7: onCreateViewHolder

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    FrameLayout contentView = new FrameLayout(LiteIconActivityV1.this);
    int gridW = (int) (displayMetrics.density * GRID_W_IN_DP);
    int gridH = (int) (displayMetrics.density * GRID_H_IN_DP);
    ViewGroup.LayoutParams lpCv = new ViewGroup.LayoutParams(gridW, gridH);
    contentView.setLayoutParams(lpCv);

    ImageView ivIcon = new ImageView(LiteIconActivityV1.this);
    ivIcon.setTag("iv");
    ivIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ivIcon.setClickable(true);
    ivIcon.setBackgroundResource(getClickBg());
    int iconSize = (int) (displayMetrics.density * ICON_SIZE_IN_DP);
    FrameLayout.LayoutParams lpIv = new FrameLayout.LayoutParams(iconSize, iconSize);
    lpIv.gravity = Gravity.CENTER;
    ivIcon.setLayoutParams(lpIv);
    contentView.addView(ivIcon);

    return new IconHolder(contentView);
}
 
开发者ID:by-syk,项目名称:NanoIconPackLite,代码行数:22,代码来源:LiteIconActivityV1.java

示例8: initPointView

import android.widget.ImageView; //导入方法依赖的package包/类
public void initPointView(int size) {
    layout = new LinearLayout(context);
    for (int i = 0; i < size; i++) {
        ImageView imageView = new ImageView(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20, 20);
        params.leftMargin = 8;
        params.gravity = Gravity.CENTER;
        imageView.setLayoutParams(params);
        if (i == 0) {
            imageView.setBackgroundResource(R.drawable.ic_point_checked);
        } else {
            imageView.setBackgroundResource(R.drawable.ic_point_normal);
        }
        layout.addView(imageView);
    }
    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(ALIGN_PARENT_BOTTOM);
    layoutParams.addRule(CENTER_HORIZONTAL);

    layoutParams.setMargins(12, 20, 12, 20);
    layout.setLayoutParams(layoutParams);
    addView(layout);
}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:24,代码来源:AutoScrollViewPager.java

示例9: ViewPagerIndicator

import android.widget.ImageView; //导入方法依赖的package包/类
public ViewPagerIndicator(Context context, ViewPager viewPager, LinearLayout dotLayout, int size) {
    this.context = context;
    this.viewPager = viewPager;
    this.dotLayout = dotLayout;
    this.size = size;

    for(int i = 0; i < size; i++){
        ImageView imageView = new ImageView(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 10;
        params.rightMargin = 10;
        params.height = imgSize;
        params.width = imgSize;
        if(0 ==i){
            imageView.setBackgroundResource(imgSelected);
        }else {
            imageView.setBackgroundResource(imgNoselect);
        }
        dotLayout.addView(imageView, params);
        dotViewLists.add(imageView);

    }
}
 
开发者ID:liuyanggithub,项目名称:SuperSelector,代码行数:26,代码来源:ViewPagerIndicator.java

示例10: getImageView

import android.widget.ImageView; //导入方法依赖的package包/类
private View getImageView(Context context, String imgUrl) {
    /* 设置某一页面的view */
    RelativeLayout relativeLayout = new RelativeLayout(context);
    ImageView imageView = new ImageView(context);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setLayoutParams(layoutParams);
    // 设置一个半透明的黑色背景,防止白字受白色图片干扰而无法显示
    ImageView background = new ImageView(context);
    background.setLayoutParams(layoutParams);
    background.setBackgroundResource(R.color.colorCycleViewBannerBackground);
    relativeLayout.addView(imageView);
    relativeLayout.addView(background);
    Picasso.with(context).load(imgUrl).into(imageView);
    return relativeLayout;
}
 
开发者ID:hgs1217,项目名称:Paper-Melody,代码行数:18,代码来源:MusicHallCycleViewPager.java

示例11: updatePointView

import android.widget.ImageView; //导入方法依赖的package包/类
public void updatePointView(int position) {
    int size = layout.getChildCount();
    for (int i = 0; i < size; i++) {
        ImageView imageView = (ImageView) layout.getChildAt(i);
        if (i == position) {
            imageView.setBackgroundResource(R.drawable.ic_point_checked);
        } else {
            imageView.setBackgroundResource(R.drawable.ic_point_normal);
        }
    }
}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:12,代码来源:AutoScrollViewPager.java

示例12: initAvatar

import android.widget.ImageView; //导入方法依赖的package包/类
private void initAvatar(ImageView avatar, Post post) {
    String avatar_url = this.user.avatar_url;
    if (post.user != null) {
        avatar_url = post.user.avatar_url;
    }
    if (TextUtils.isEmpty(avatar_url)) {
        avatar.setBackgroundResource(R.drawable.aa0);
    } else {
        this.imageLoader.displayImage(avatar_url, avatar, ImageLoaderOptions.avatar());
    }
    avatar.setOnClickListener(new AvatarClickListener(post));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:UserTimelineAdapter.java

示例13: setupPillChildView

import android.widget.ImageView; //导入方法依赖的package包/类
private LinearLayout setupPillChildView(String pillMessage, boolean isPressed, int imgResource) {
    final LinearLayout lnlContainer = (LinearLayout) LayoutInflater.from(getContext())
            .inflate(R.layout.pills_box_layout, this, false);
    lnlContainer.setBackgroundResource(backgroundPill);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(pillMarginLeft, pillMarginTop, pillMarginRight, pillMarginBottom);
    lnlContainer.setLayoutParams(layoutParams);

    if (isPressed) {
        lnlContainer.setBackgroundResource(backgroundPillSelected);
    } else {
        lnlContainer.setBackgroundResource(backgroundPill);
    }

    //Inflating LinearLayout child for customization
    LinearLayout lnlChild = (LinearLayout) lnlContainer.findViewById(R.id.lnlChild);
    lnlChild.setPadding(pillPaddingLeft, pillPaddingTop, pillPaddingRight, pillPaddingBottom);

    //Inflating ImageView
    CirculateImageView civContact = (CirculateImageView) lnlContainer.findViewById(R.id.civContact);

    if (hideContactIcon) {
        civContact.setVisibility(View.VISIBLE);
    } else {
        civContact.setVisibility(View.GONE);
    }

    if (imgResource == 0) {
        civContact.setImageResource(R.drawable.ic_orbismobile);
    } else {
        civContact.setImageResource(imgResource);
    }
    //Inflating TextView child for customization
    TextView lblMessage = (TextView) lnlContainer.findViewById(R.id.lblMessage);
    lblMessage.setText(pillMessage);
    lblMessage.setTextColor(pillTextColor);
    //Inflating imgClose view for customization
    ImageView imgClose = (ImageView) lnlContainer.findViewById(R.id.imgClose);
    imgClose.setBackgroundResource(pillCloseIcon);
    if (hideCloseIcon) {
        imgClose.setVisibility(View.VISIBLE);
    } else {
        imgClose.setVisibility(View.GONE);
    }
    MarginLayoutParams marginLayoutParams = (MarginLayoutParams) imgClose.getLayoutParams();
    marginLayoutParams.leftMargin = closeIconMarginLeft;
    imgClose.setLayoutParams(marginLayoutParams);
    imgClose.setOnClickListener(this);
    lnlContainer.setOnClickListener(this);
    return lnlContainer;
}
 
开发者ID:orbismobile,项目名称:android-MaterialPillsBox,代码行数:52,代码来源:MaterialPillsBox.java

示例14: onBindViewHolder

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(RecyclerViewAdapter.RecyclerViewHolder holder, int position)
{
	LocalAlbumActivity activity = mWeakReference.get();
	ImageView image = holder.findViewById(R.id.image);
	ImageView background = holder.findViewById(R.id.background);
	TextView name_number = holder.findViewById(R.id.name_number);
	
	AlbumInfo albumInfo = activity.mImageAdapter.getItem(position);
	name_number.setText(activity.getString(R.string.name_number, albumInfo.getName(), albumInfo.getPicnum()));
	background.setBackgroundResource(IMAGE_BACKGROUND[position % IMAGE_BACKGROUND.length]);
	activity.mImageLoader.displayImage(albumInfo.getCoverurl(), image, activity.mOptions);
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:14,代码来源:LocalAlbumActivity.java

示例15: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
public void onCreate() {
    LinearLayout llPage = new LinearLayout(getContext());
    llPage.setBackgroundColor(-657931);
    llPage.setOrientation(1);
    this.activity.setContentView(llPage);
    this.llTitle = new TitleLayout(getContext());
    int resId = R.getBitmapRes(getContext(), "title_back");
    if (resId > 0) {
        this.llTitle.setBackgroundResource(resId);
    }
    this.llTitle.getBtnBack().setOnClickListener(this);
    resId = R.getStringRes(getContext(), "multi_share");
    if (resId > 0) {
        this.llTitle.getTvTitle().setText(resId);
    }
    this.llTitle.getBtnRight().setVisibility(0);
    resId = R.getStringRes(getContext(), SportPlanFragment.COURSE_STATUS_FINISH);
    if (resId > 0) {
        this.llTitle.getBtnRight().setText(resId);
    }
    this.llTitle.getBtnRight().setOnClickListener(this);
    this.llTitle.setLayoutParams(new LayoutParams(-1, -2));
    llPage.addView(this.llTitle);
    FrameLayout flPage = new FrameLayout(getContext());
    LayoutParams lpFl = new LayoutParams(-1, -2);
    lpFl.weight = 1.0f;
    flPage.setLayoutParams(lpFl);
    llPage.addView(flPage);
    PullToRefreshView followList = new PullToRefreshView(getContext());
    followList.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
    flPage.addView(followList);
    this.adapter = new FollowAdapter(followList);
    this.adapter.setPlatform(this.platform);
    followList.setAdapter(this.adapter);
    this.adapter.getListView().setOnItemClickListener(this);
    ImageView ivShadow = new ImageView(getContext());
    resId = R.getBitmapRes(getContext(), "title_shadow");
    if (resId > 0) {
        ivShadow.setBackgroundResource(resId);
    }
    ivShadow.setLayoutParams(new FrameLayout.LayoutParams(-1, -2));
    flPage.addView(ivShadow);
    followList.performPulling(true);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:45,代码来源:FollowListPage.java


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