本文整理汇总了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) {
}
});
}
});
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
});
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
});
}