當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.setBackgroundDrawable方法代碼示例

本文整理匯總了Java中android.widget.Button.setBackgroundDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.setBackgroundDrawable方法的具體用法?Java Button.setBackgroundDrawable怎麽用?Java Button.setBackgroundDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.Button的用法示例。


在下文中一共展示了Button.setBackgroundDrawable方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initBlackListStatusView

import android.widget.Button; //導入方法依賴的package包/類
private void initBlackListStatusView() {
    if (mIsFriendsRelationship) {
        Button rightButton = getHeadRightButton();
        rightButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.main_activity_contact_more));
        rightButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                RongIM.getInstance().getBlacklistStatus(mFriend.getUserId(), new RongIMClient.ResultCallback<RongIMClient.BlacklistStatus>() {
                    @Override
                    public void onSuccess(RongIMClient.BlacklistStatus blacklistStatus) {
                        SinglePopWindow morePopWindow = new SinglePopWindow(UserDetailActivity.this, mFriend, blacklistStatus);
                        morePopWindow.showPopupWindow(v);
                    }

                    @Override
                    public void onError(RongIMClient.ErrorCode e) {

                    }
                });
            }
        });
    }
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:24,代碼來源:UserDetailActivity.java

示例2: b

import android.widget.Button; //導入方法依賴的package包/類
public void b(Button button) {
    Drawable stateListDrawable = new StateListDrawable();
    Drawable a = this.a.b("com.tencent.plus.gray_normal.png");
    Drawable a2 = this.a.b("com.tencent.plus.gray_down.png");
    Drawable a3 = this.a.b("com.tencent.plus.gray_disable.png");
    stateListDrawable.addState(View.PRESSED_ENABLED_STATE_SET, a2);
    stateListDrawable.addState(View.ENABLED_FOCUSED_STATE_SET, a);
    stateListDrawable.addState(View.ENABLED_STATE_SET, a);
    stateListDrawable.addState(View.FOCUSED_STATE_SET, a);
    stateListDrawable.addState(View.EMPTY_STATE_SET, a3);
    button.setBackgroundDrawable(stateListDrawable);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:13,代碼來源:ImageActivity.java

示例3: setButton

import android.widget.Button; //導入方法依賴的package包/類
static void setButton(@ColorInt int bgColor, @ColorInt int color, Button button, boolean colored) {
    if (!colored) {
        if (bgColor!=-1)
            color = bgColor;
        else
            color = Color.parseColor("#ffffff");
    }

    int selectedColor = isColorLight(color) ?
            ColorUtils.blendARGB(color, Color.parseColor("#000000"), 0.15f) :
            ColorUtils.blendARGB(color, Color.parseColor("#FFFFFF"), 0.20f);

    GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
            new int[]{selectedColor, selectedColor});
    GradientDrawable drawable2 = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
            new int[]{color, color});

    drawable.setCornerRadius(dpToPx(2));
    drawable2.setCornerRadius(dpToPx(2));

    StateListDrawable button1bg = new StateListDrawable();
    button1bg.addState(new int[] {android.R.attr.state_pressed}, drawable);
    button1bg.addState(new int[] {}, drawable2);
    button1bg.setExitFadeDuration(250);

    button.setBackgroundDrawable(button1bg);
}
 
開發者ID:marcoscgdev,項目名稱:DialogSheet,代碼行數:28,代碼來源:Utils.java

示例4: setKeyColor

import android.widget.Button; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public static void setKeyColor(Button key, Drawable bg) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        key.setBackgroundDrawable(bg);
    } else {
        key.setBackground(bg);
    }
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:10,代碼來源:Key.java

示例5: setBarTheme

import android.widget.Button; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private static void setBarTheme(Activity activity, int theme) {
	Button menuButton = (Button)activity.findViewById(R.id.menuButton);
	Button searchButton = (Button)activity.findViewById(R.id.searchButton);
	Button webSearchButton = (Button)activity.findViewById(R.id.webSearchButton);
	EditText searchField = (EditText)activity.findViewById(R.id.textField);
	Resources resources = activity.getResources();
	switch (theme) {
		case DEFAULT_THEME:
		case LIGHT:
		case WALLPAPER_LIGHT:
			if (Build.VERSION.SDK_INT >= 16) {
				menuButton.setBackground(resources.getDrawable(R.drawable.menu_bg));
				searchButton.setBackground(resources.getDrawable(R.drawable.search_bg));
				webSearchButton.setBackground(resources.getDrawable(R.drawable.web_search_bg));
			} else {
				menuButton.setBackgroundDrawable(resources.getDrawable(R.drawable.menu_bg));
				searchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.search_bg));
				webSearchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.web_search_bg));
			}
			searchField.setTextColor(Color.WHITE);
			break;
		default:
			if (Build.VERSION.SDK_INT >= 16) {
				menuButton.setBackground(resources.getDrawable(R.drawable.menu_dark_bg));
				searchButton.setBackground(resources.getDrawable(R.drawable.search_dark_bg));
				webSearchButton.setBackground(resources.getDrawable(R.drawable.web_search_dark_bg));
			} else {
				menuButton.setBackgroundDrawable(resources.getDrawable(R.drawable.menu_dark_bg));
				searchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.search_dark_bg));
				webSearchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.web_search_dark_bg));
			}
			searchField.setTextColor(Color.BLACK);
	}
}
 
開發者ID:HenriDellal,項目名稱:emerald,代碼行數:36,代碼來源:Themer.java

示例6: onCreate

import android.widget.Button; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pub_list);
    setTitle(R.string.de_actionbar_set_public);
    Button rightButton = getHeadRightButton();
    rightButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.de_ic_add));
    rightButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(PublicServiceActivity.this, PublicServiceSearchActivity.class);
            startActivity(intent);
        }
    });
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:16,代碼來源:PublicServiceActivity.java

示例7: initView

import android.widget.Button; //導入方法依賴的package包/類
protected void initView() {
    setTitle(R.string.new_friends);
    shipListView = (ListView) findViewById(R.id.shiplistview);
    isData = (TextView) findViewById(R.id.isData);
    Button rightButton = getHeadRightButton();
    rightButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.de_address_new_friend));
    rightButton.setOnClickListener(this);
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:9,代碼來源:NewFriendListActivity.java

示例8: create

import android.widget.Button; //導入方法依賴的package包/類
public static RelativeLayout create(Context context) {
	SizeHelper.prepare(context);

	RelativeLayout root = new RelativeLayout(context);
	root.setId(ResHelper.getIdRes(context, "rl_lv_item_bg"));
	AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
			SizeHelper.fromPxWidth(95));
	root.setLayoutParams(params);
	int padding = SizeHelper.fromPxWidth(14);
	root.setPadding(padding, padding, padding, padding);
	root.setGravity(Gravity.CENTER_VERTICAL);
	root.setBackgroundColor(0xffffffff);

	AsyncImageView contactImage = new AsyncImageView(context);
	contactImage.setId(ResHelper.getIdRes(context, "iv_contact"));
	RelativeLayout.LayoutParams contactImageParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(64),
			SizeHelper.fromPxWidth(64));
	contactImageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	contactImage.setLayoutParams(contactImageParams);
	contactImage.setScaleType(ScaleType.FIT_CENTER);
	root.addView(contactImage);

	LinearLayout wrapper = new LinearLayout(context);
	RelativeLayout.LayoutParams wrapperParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
			RelativeLayout.LayoutParams.WRAP_CONTENT);
	wrapperParams.addRule(RelativeLayout.RIGHT_OF, ResHelper.getIdRes(context, "iv_contact"));
	wrapperParams.addRule(RelativeLayout.CENTER_VERTICAL);
	wrapperParams.leftMargin = SizeHelper.fromPxWidth(12);
	wrapper.setLayoutParams(wrapperParams);
	wrapper.setOrientation(LinearLayout.VERTICAL);
	root.addView(wrapper);

	TextView name = new TextView(context);
	name.setId(ResHelper.getIdRes(context, "tv_name"));
	LinearLayout.LayoutParams nameParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	name.setLayoutParams(nameParams);
	name.setTextColor(0xff333333);
	name.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(28));
	wrapper.addView(name);

	TextView contact = new TextView(context);
	contact.setId(ResHelper.getIdRes(context, "tv_contact"));
	LinearLayout.LayoutParams contactParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	contact.setLayoutParams(contactParams);
	contact.setTextColor(0xff999999);
	contact.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	wrapper.addView(contact);

	Button add = new Button(context);
	add.setId(ResHelper.getIdRes(context, "btn_add"));
	RelativeLayout.LayoutParams addParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(92),
			SizeHelper.fromPxWidth(46));
	addParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	addParams.addRule(RelativeLayout.CENTER_VERTICAL);
	add.setLayoutParams(addParams);
	int resid = ResHelper.getStringRes(context, "smssdk_add_contact");
	add.setText(resid);
	add.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(22));
	add.setTextColor(0xff797979);
	//resid = R.getBitmapRes(context, "smssdk_corners_bg");
	add.setBackgroundDrawable(DrawableHelper.createCornerBg(context));
	add.setPadding(0, 0, 0, 0);
	root.addView(add);

	return root;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:69,代碼來源:ContactsListviewItemLayout.java

示例9: initPageView

import android.widget.Button; //導入方法依賴的package包/類
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);
	flPage.setBackgroundDrawable(new ColorDrawable(0x55000000));

	// container of the platform gridview
	llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	llPage.setBackgroundDrawable(new ColorDrawable(0xffffffff));
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// gridview
	grid = new PlatformGridView(getContext());
	grid.setEditPageBackground(getBackgroundView());
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// cancel button
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xff3a65ff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	int resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, com.mob.tools.utils.R.dipToPx(getContext(), 5));

	resId = getBitmapRes(getContext(), "classic_platform_corners_bg");
	if(resId > 0){
		btnCancel.setBackgroundResource(resId);
	}else {
	    btnCancel.setBackgroundDrawable(new ColorDrawable(0xffffffff));
	}

	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, com.mob.tools.utils.R.dipToPx(getContext(), 45));
	int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:52,代碼來源:PlatformListPage.java

示例10: onCreate

import android.widget.Button; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.setting);
    
    ctx = getApplicationContext();
    wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    WIDTH = wm.getDefaultDisplay().getWidth();
    HEIGHT = wm.getDefaultDisplay().getHeight();
    DP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, ctx.getResources().getDisplayMetrics());
    
    /*---main layout---*/
    main = new LinearLayout(ctx);
    main.setOrientation(1);
    main.setPadding(15 * DP, 10 * DP, 15 * DP, 5 * DP);
    
    /*---head color setting---*/
    LinearLayout head = new LinearLayout(ctx);
    head.setOrientation(0);
    head.setPadding(15 * DP, 5 * DP, 15 * DP, 5 * DP);
    
    TextView tv = new TextView(ctx);
    tv.setText("Head 색상 바꾸기");
    tv.setTextSize(20);
    tv.setTextColor(Color.BLACK);
    head.addView(tv, WIDTH - 95 * DP, 35 * DP);
    
    Button colorPick = new Button(ctx);
    colorPick.setText("");
    GradientDrawable gradient = new GradientDrawable();
    gradient.setStroke(3 * DP, Color.GRAY);
    gradient.setCornerRadius(500 * DP);
    gradient.setColor(Color.rgb(90, 110, 255));
    colorPick.setBackgroundDrawable(gradient);
    head.addView(colorPick, 35 * DP, 35 * DP);
    
    main.addView(head);
    main.addView(line(Color.GRAY));
    
    setContentView(main);
}
 
開發者ID:AstinPE,項目名稱:FloatingApps,代碼行數:42,代碼來源:SettingActivity.java

示例11: initView

import android.widget.Button; //導入方法依賴的package包/類
private void initView(Context context) {
    mContext = context;
    EmoticonHandler.getInstance(context).loadEmoticonsToMemory();
    LayoutInflater.from(context).inflate(R.layout.view_keyboardbar, this);
    rl_input = (RelativeLayout) findViewById(R.id.rl_input);
    lyBottomLayout = (LinearLayout) findViewById(R.id.ly_foot_func);
    btnEmoticon = (ImageView) findViewById(R.id.btn_face);
    btnVoiceOrText = (ImageView) findViewById(R.id.btn_voice_or_text);
    btnRecording = (AudioRecordButton) findViewById(R.id.bar_recording);
    btnMedia = (ImageView) findViewById(R.id.btn_multimedia);
    btnSend = (Button) findViewById(R.id.btn_send);
    if (mBtnSendBg != null) {
        btnSend.setBackgroundDrawable(mBtnSendBg);
    }
    etInputArea = (HadEditText) findViewById(R.id.et_chat);
    setAutoHeightLayoutView(lyBottomLayout);
    btnVoiceOrText.setOnClickListener(new VoiceTextClickListener());
    btnMedia.setOnClickListener(new MediaClickListener());
    btnMedia.setVisibility(GONE);
    btnEmoticon.setOnClickListener(new FaceClickListener());
    btnEmoticon.setVisibility(GONE);
    btnSend.setOnClickListener(new SendClickListener());
    btnRecording.setOnRecordingTouchListener(new AudioRecordButton.OnRecordingTouchListener() {
        @Override
        public void onRecordingAction(AudioRecordButton audioRecordButton, RecordingAction action) {
            if (mOnChatKeyBoardListener != null) {
                mOnChatKeyBoardListener.onRecordingAction(audioRecordButton, action);
            }
        }
    });
    etInputArea.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (!etInputArea.isFocused()) {
                etInputArea.setFocusable(true);
                etInputArea.setFocusableInTouchMode(true);
            }
            return false;
        }
    });
    etInputArea.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                setEditableState(true);
            } else {
                setEditableState(false);
            }
        }
    });
    etInputArea.setOnTextChangedInterface(new HadEditText.OnTextChangedInterface() {
        @Override
        public void onTextChanged(CharSequence arg0) {
            if (!isShowMediaButton || isLimitedOnlyText) {
                return;
            }
            String str = arg0.toString();
            if (TextUtils.isEmpty(str)) {
                btnMedia.setVisibility(VISIBLE);
                btnSend.setVisibility(GONE);
            } else {
                btnMedia.setVisibility(GONE);
                btnSend.setVisibility(VISIBLE);
            }
        }
    });
}
 
開發者ID:yangchaojiang,項目名稱:ChatKeyboard-master,代碼行數:68,代碼來源:ChatKeyboardLayout.java


注:本文中的android.widget.Button.setBackgroundDrawable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。