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


Java ImageView.setBackgroundDrawable方法代码示例

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


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

示例1: initUI

import android.widget.ImageView; //导入方法依赖的package包/类
private void initUI(View view) {
    callTypeTextView = (TextView) view.findViewById(R.id.call_type);

    ImageView callerAvatarImageView = (ImageView) view.findViewById(R.id.image_caller_avatar);
    callerAvatarImageView.setBackgroundDrawable(getBackgroundForCallerAvatar(currentSession.getCallerID()));

    TextView callerNameTextView = (TextView) view.findViewById(R.id.text_caller_name);

    QBUser callerUser = qbUserDbManager.getUserById(currentSession.getCallerID());
    callerNameTextView.setText(UsersUtils.getUserNameOrId(callerUser, currentSession.getCallerID()));

    TextView otherIncUsersTextView = (TextView) view.findViewById(R.id.text_other_inc_users);
    otherIncUsersTextView.setText(getOtherIncUsersNames());

    alsoOnCallText = (TextView) view.findViewById(R.id.text_also_on_call);
    setVisibilityAlsoOnCallTextView();

    rejectButton = (ImageButton) view.findViewById(R.id.image_button_reject_call);
    takeButton = (ImageButton) view.findViewById(R.id.image_button_accept_call);
}
 
开发者ID:mobilemaster128,项目名称:quickblox-android,代码行数:21,代码来源:IncomeCallFragment.java

示例2: initViews

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void initViews(View view) {
    super.initViews(view);
    timerChronometer = (Chronometer) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.chronometer_timer_audio_call);

    ImageView firstOpponentAvatarImageView = (ImageView) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.image_caller_avatar);
    firstOpponentAvatarImageView.setBackgroundDrawable(UiUtils.getColorCircleDrawable(opponents.get(0).getId()));

    alsoOnCallText = (TextView) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.text_also_on_call);
    setVisibilityAlsoOnCallTextView();

    firstOpponentNameTextView = (TextView) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.text_caller_name);
    firstOpponentNameTextView.setText(opponents.get(0).getFullName());

    otherOpponentsTextView = (TextView) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.text_other_inc_users);
    otherOpponentsTextView.setText(getOtherOpponentsNames());

    audioSwitchToggleButton = (ToggleButton) view.findViewById(com.mobilemaster.quickblox.groupchatwebrtc.R.id.toggle_speaker);
    audioSwitchToggleButton.setVisibility(View.VISIBLE);

    actionButtonsEnabled(false);
}
 
开发者ID:mobilemaster128,项目名称:quickblox-android,代码行数:23,代码来源:AudioConversationFragment.java

示例3: setPreviewColor

import android.widget.ImageView; //导入方法依赖的package包/类
private void setPreviewColor() {
	if (mView == null) return;
	ImageView iView = new ImageView(getContext());
	LinearLayout widgetFrameView = ((LinearLayout)mView.findViewById(android.R.id.widget_frame));
	if (widgetFrameView == null) return;
	widgetFrameView.setVisibility(View.VISIBLE);
	widgetFrameView.setPadding(
		widgetFrameView.getPaddingLeft(),
		widgetFrameView.getPaddingTop(),
		(int)(mDensity * 8),
		widgetFrameView.getPaddingBottom()
	);
	// remove already create preview image
	int count = widgetFrameView.getChildCount();
	if (count > 0) {
		widgetFrameView.removeViews(0, count);
	}
	widgetFrameView.addView(iView);
	widgetFrameView.setMinimumWidth(0);
	iView.setBackgroundDrawable(new AlphaPatternDrawable((int)(5 * mDensity)));
	iView.setImageBitmap(getPreviewBitmap());
}
 
开发者ID:Bregnet,项目名称:TextView_CustomEdit_CustomColor,代码行数:23,代码来源:ColorPickerPreference.java

示例4: setImageDrawable

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[] {
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
 
开发者ID:liuyanggithub,项目名称:SuperSelector,代码行数:26,代码来源:ImageWorker.java

示例5: setResource

import android.widget.ImageView; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@SuppressWarnings("deprecation")
static boolean setResource(ImageView view, boolean isSrc, int resId) {
	Resources res = view.getResources();
	if (res != null) {
		try {
			GifDrawable d = new GifDrawable(res, resId);
			if (isSrc) {
				view.setImageDrawable(d);
			} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
				view.setBackground(d);
			} else {
				view.setBackgroundDrawable(d);
			}
			return true;
		} catch (Exception ignored) {
			// ignored
		}
	}
	return false;
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:22,代码来源:GifViewUtils.java

示例6: buildUI

import android.widget.ImageView; //导入方法依赖的package包/类
private void buildUI() {
	setOrientation(LinearLayout.HORIZONTAL);
	setGravity(Gravity.CENTER_HORIZONTAL);
	setWillNotDraw(false);

	imgSeekSelector = new ImageView(getContext());
	imgSeekSelector.setImageDrawable(seekSelector);
	LayoutParams paramsSeek = new LayoutParams(seekSelector
			.getIntrinsicWidth(), seekSelector.getIntrinsicHeight());
	addView(imgSeekSelector, paramsSeek);

	imgAlpha = new ImageView(getContext());
	imgAlpha.setBackgroundDrawable(getContext().getResources().getDrawable(R.drawable.transparentbackrepeat));
	imgAlpha.setScaleType(ScaleType.FIT_XY);
	LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
			LayoutParams.FILL_PARENT);
	params.setMargins(0, getOffset(), 0, getSelectorOffset());
	addView(imgAlpha, params);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:20,代码来源:HsvAlphaSelectorView.java

示例7: setImageDrawable

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[]{
                        new ColorDrawable(Color.TRANSPARENT),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:26,代码来源:ImageWorker.java

示例8: setCount

import android.widget.ImageView; //导入方法依赖的package包/类
public void setCount(int count) {
    mCount = count;
    setIndicatorFocusColor(indicatorFocusColor);
    setIndicatorNormalColor(indicatorNormalColor);
    mLinearLayout = new LinearLayout(mContext);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(indicatorSize, indicatorSize);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.setMargins(densityUtil.dip2px(mContext, 2), densityUtil.dip2px(mContext, 0),
            densityUtil.dip2px(mContext, 2), densityUtil.dip2px(mContext, 0));
    mLinearLayout.setGravity(Gravity.CENTER);
    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.topMargin = densityUtil.dip2px(mContext, 10);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, TRUE);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL, TRUE);
    addView(mLinearLayout, params);

    //动态添加小圆点指示器
    for (int i = 0; i < mCount; i++) {
        //创建一个ImageView用于存放一个小圆点
        ImageView indicatorImage = new ImageView(mContext);
        if (i == 0) {
            //为了兼容,使用setBackgroundDrawable
            indicatorImage.setBackgroundDrawable(indicatorFocus);
        } else {
            indicatorImage.setBackgroundDrawable(indicatorNormal);
        }
        mLinearLayout.addView(indicatorImage, layoutParams);
    }

    ViewPagerAdapter adapter = new ViewPagerAdapter();
    mViewPager.setAdapter(adapter);
    mViewPager.setOffscreenPageLimit(mCount);
    int targetItemPosition = Integer.MAX_VALUE / 2 - Integer.MAX_VALUE / 2 % count;
    mViewPager.setCurrentItem(targetItemPosition);
}
 
开发者ID:wheat7,项目名称:GalleryCycleImageView,代码行数:36,代码来源:GalleryCycleImageView.java

示例9: addTab

import android.widget.ImageView; //导入方法依赖的package包/类
protected void addTab(int index, CharSequence text, int iconResId) {
    TabView tabView = new TabView(this, getContext(), text);
    tabView.setIndex(index);
    tabView.setFocusable(true);
    tabView.setOnClickListener(this.mTabClickListener);
    if (iconResId != 0) {
        tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
    }
    int width = this.mMeanWidth == -1 ? getTabWidth(text) : this.mMeanWidth;
    if (this.mMeanWidth != -1) {
        tabView.setSize(this.mMeanWidth, UIsUtils.dipToPx(38.0f));
    } else {
        tabView.setSize(width, UIsUtils.dipToPx(38.0f));
    }
    RelativeLayout relativeLayout = new RelativeLayout(this.mContext);
    relativeLayout.setGravity(17);
    relativeLayout.setLayoutParams(new LayoutParams(-2, UIsUtils.dipToPx(38.0f)));
    LayoutParams params = new LayoutParams(-2, UIsUtils.dipToPx(38.0f));
    params.setMargins(TAB_MARGIN, 0, TAB_MARGIN, 0);
    tabView.setLayoutParams(params);
    relativeLayout.addView(tabView);
    if (this.mIsHome) {
        ThemeDataManager.getInstance(this.mContext).setContentTheme(tabView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR);
    }
    ImageView imageView = new ImageView(this.mContext);
    LayoutParams imageViewParams = new LayoutParams(width, UIsUtils.dipToPx(2.0f));
    imageViewParams.setMargins(TAB_MARGIN, UIsUtils.dipToPx(36.0f), TAB_MARGIN, 0);
    imageView.setLayoutParams(imageViewParams);
    relativeLayout.addView(imageView);
    imageView.setBackgroundDrawable(getResources().getDrawable(2130838177));
    if (this.mIsHome) {
        ThemeDataManager.getInstance(this.mContext).setShapeSelectorViewTheme(imageView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR, 2, true);
    }
    this.mTabLayout.addView(relativeLayout);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:36,代码来源:ChannelTabPageIndicator.java

示例10: setBackground

import android.widget.ImageView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public static void setBackground(Drawable imagebakground,ImageView view){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(imagebakground);
    } else {
        view.setBackgroundDrawable(imagebakground);
    }
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:10,代码来源:VersionUtils.java

示例11: TweetSelectImageHolder

import android.widget.ImageView; //导入方法依赖的package包/类
private TweetSelectImageHolder(View itemView, View.OnClickListener clickListener) {
    super(itemView);

    mImage = (ImageView) itemView.findViewById(R.id.iv_content);
    mDelete = (ImageView) itemView.findViewById(R.id.iv_delete);

    mDelete.setVisibility(View.GONE);
    mImage.setImageResource(R.mipmap.ic_tweet_add);
    mImage.setOnClickListener(clickListener);
    mImage.setBackgroundDrawable(null);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:12,代码来源:TweetSelectImageAdapter.java

示例12: getView

import android.widget.ImageView; //导入方法依赖的package包/类
@SuppressLint({ "ViewHolder", "InflateParams" })
public View getView(int position, View convertView, ViewGroup parent) {
	convertView = LayoutInflater.from(context).inflate(R.layout.nim_emoji_item, null);
	ImageView emojiThumb = (ImageView) convertView.findViewById(R.id.imgEmoji);
	int count = EmojiManager.getDisplayCount();
	int index = startIndex + position;
	if (position == EmoticonView.EMOJI_PER_PAGE || index == count) {
		emojiThumb.setBackgroundResource(R.drawable.nim_emoji_del);
	} else if (index < count) {
           emojiThumb.setBackgroundDrawable(EmojiManager.getDisplayDrawable(context, index));
	}	
		
	return convertView;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:15,代码来源:EmojiAdapter.java

示例13: getItemView

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) {

    View x = null;
    if (x == null) {


        LinearLayout base = new LinearLayout(context);
        base.setOrientation(LinearLayout.VERTICAL);
        base.setGravity(Gravity.CENTER_VERTICAL);

        LinearLayout l = new LinearLayout(context);
        l.setOrientation(LinearLayout.HORIZONTAL);
        l.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT));
        l.setPadding(50,0,50,0);


        picup = new ImageView(context);
        picup.setScaleType(ImageView.ScaleType.CENTER);
        picup.setVisibility(View.GONE);
        picup.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.attach_file));


        statusup = new ImageView(context);
        statusup.setScaleType(ImageView.ScaleType.CENTER);
        statusup.setVisibility(View.GONE);
        statusup.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.attach_contact));

        phoneup = new ImageView(context);
        phoneup.setScaleType(ImageView.ScaleType.CENTER);
        phoneup.setVisibility(View.GONE);
        phoneup.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.specific_phoneup));

        isonetime = new ImageView(context);
        isonetime.setScaleType(ImageView.ScaleType.CENTER);
        isonetime.setVisibility(View.GONE);
        isonetime.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.specific_one_time));

        setVisiblity(users.get(position));

        l.addView(picup , 100 , 100);
        l.addView(statusup , 100 , 100);
        l.addView(phoneup , 100 , 100);
        l.addView(isonetime , 100 , 100);



        x = new CustomUserCell(context, 5, 1, false);
        base.addView(x , LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT , LayoutHelper.WRAP_CONTENT ));

        base.addView(l , LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT , LayoutHelper.WRAP_CONTENT ));
        base.addView(new DividerCell(context) , LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT , LayoutHelper.WRAP_CONTENT ));


        convertView = base ;
        ((CustomUserCell) x).setStatusColors(0xffa8a8a8, 0xff3b84c0);
        convertView.setTag("Contacts");
    }


    TLRPC.User user = MessagesController.getInstance().getUser(users.get(position).getUid());
    ((CustomUserCell) x).setData(user, null,null, 0);
    convertView.setTag("Contacts");
    return convertView;
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:66,代码来源:userAdapter.java

示例14: startDragging

import android.widget.ImageView; //导入方法依赖的package包/类
private void startDragging(Bitmap bm, int x, int y) {
    stopDragging();

    if (getParent() != null) {
        getParent().requestDisallowInterceptTouchEvent(true);
    }
    mWindowParams = new WindowManager.LayoutParams();
    if (mCenter) {
        mWindowParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
    } else {
        mWindowParams.gravity = Gravity.TOP | Gravity.END;
    }
    mWindowParams.x = x - mDragPointX + mXOffset;
    mWindowParams.y = y - mDragPointY + mYOffset;

    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;

    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
    mWindowParams.format = PixelFormat.TRANSLUCENT;

    Context context = getContext();
    ImageView v = new ImageView(context);
    // int backGroundColor =
    // context.getResources().getColor(R.color.dragndrop_background);
    // v.setBackgroundColor(backGroundColor);

    v.setBackgroundDrawable(ThemeUtils.colorizeResourceDrawableInvert(
            R.drawable.abc_menu_dropdown_panel_holo_light, context));
    v.setImageBitmap(bm);
    mDragBitmap = bm;

    mWindowManager = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
    mWindowManager.addView(v, mWindowParams);
    mDragView = v;
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:42,代码来源:TouchInterceptor.java


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