當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。