本文整理了Java中android.widget.Button.setCompoundDrawablesWithIntrinsicBounds()
方法的一些代码示例,展示了Button.setCompoundDrawablesWithIntrinsicBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.setCompoundDrawablesWithIntrinsicBounds()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:setCompoundDrawablesWithIntrinsicBounds
暂无
代码示例来源:origin: JohnPersano/SuperToasts
button.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat
.getDrawable(mContext.getResources(),
this.mStyle.buttonIconResource,
代码示例来源:origin: dkim0419/SoundRecorder
private void onPauseRecord(boolean pause) {
if (pause) {
//pause recording
mPauseButton.setCompoundDrawablesWithIntrinsicBounds
(R.drawable.ic_media_play ,0 ,0 ,0);
mRecordingPrompt.setText((String)getString(R.string.resume_recording_button).toUpperCase());
timeWhenPaused = mChronometer.getBase() - SystemClock.elapsedRealtime();
mChronometer.stop();
} else {
//resume recording
mPauseButton.setCompoundDrawablesWithIntrinsicBounds
(R.drawable.ic_media_pause ,0 ,0 ,0);
mRecordingPrompt.setText((String)getString(R.string.pause_recording_button).toUpperCase());
mChronometer.setBase(SystemClock.elapsedRealtime() + timeWhenPaused);
mChronometer.start();
}
}
}
代码示例来源:origin: adolfAn/FBReader_AS
/**
* Sets the icon resource of the button in
* a BUTTON {@link com.github.johnpersano.supertoasts.SuperToast.Type} {@value #TAG}.
*
* @param buttonIcon {@link com.github.johnpersano.supertoasts.SuperToast.Icon}
*/
public void setButtonIcon(int buttonIcon) {
if (mType != Type.BUTTON) {
Log.w(TAG, "setButtonIcon()" + ERROR_NOTBUTTONTYPE);
}
this.mButtonIcon = buttonIcon;
if (mButton != null) {
mButton.setCompoundDrawablesWithIntrinsicBounds(mActivity
.getResources().getDrawable(buttonIcon), null, null, null);
}
}
代码示例来源:origin: adolfAn/FBReader_AS
/**
* Sets the icon resource of the button in a BUTTON
* {@link com.github.johnpersano.supertoasts.SuperToast.Type} {@value #TAG}.
*
* @param buttonIcon {@link com.github.johnpersano.supertoasts.SuperToast.Icon}
*/
public void setButtonIcon(int buttonIcon) {
if (mType != Type.BUTTON) {
Log.e(TAG, "setButtonIcon()" + ERROR_NOTBUTTONTYPE);
}
this.mButtonIcon = buttonIcon;
if (mButton != null) {
mButton.setCompoundDrawablesWithIntrinsicBounds(mActivity
.getResources().getDrawable(buttonIcon), null, null, null);
}
}
代码示例来源:origin: adolfAn/FBReader_AS
/**
* Sets the icon resource and text of the button in
* a BUTTON {@link com.github.johnpersano.supertoasts.SuperToast.Type} {@value #TAG}.
*
* @param buttonIcon {@link com.github.johnpersano.supertoasts.SuperToast.Icon}
* @param buttonText {@link CharSequence}
*/
public void setButtonIcon(int buttonIcon, CharSequence buttonText) {
if (mType != Type.BUTTON) {
Log.w(TAG, "setButtonIcon()" + ERROR_NOTBUTTONTYPE);
}
this.mButtonIcon = buttonIcon;
if (mButton != null) {
mButton.setCompoundDrawablesWithIntrinsicBounds(mActivity
.getResources().getDrawable(buttonIcon), null, null, null);
mButton.setText(buttonText);
}
}
代码示例来源:origin: adolfAn/FBReader_AS
/**
* Sets the icon resource and text of the button in
* a BUTTON {@link com.github.johnpersano.supertoasts.SuperToast.Type} {@value #TAG}.
*
* @param buttonIcon {@link com.github.johnpersano.supertoasts.SuperToast.Icon}
* @param buttonText {@link CharSequence}
*/
public void setButtonIcon(int buttonIcon, CharSequence buttonText) {
if (mType != Type.BUTTON) {
Log.w(TAG, "setButtonIcon()" + ERROR_NOTBUTTONTYPE);
}
this.mButtonIcon = buttonIcon;
if (mButton != null) {
mButton.setCompoundDrawablesWithIntrinsicBounds(mActivity
.getResources().getDrawable(buttonIcon), null, null, null);
mButton.setText(buttonText);
}
}
代码示例来源:origin: cyclestreets/android
private void setupButtons() {
save_ = findViewById(R.id.save);
save_.setCompoundDrawablesWithIntrinsicBounds(0, 0, android.R.drawable.ic_menu_save, 0);
save_.setOnClickListener(this);
save_.setEnabled(false);
Button cancel_ = findViewById(R.id.cancel);
cancel_.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_menu_close_clear_cancel, 0, 0, 0);
cancel_.setOnClickListener(this);
}
代码示例来源:origin: BaaSBeginner/leanchat-android
private void setTopDrawable(Button v, int resId) {
v.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(resId), null, null);
}
代码示例来源:origin: msayan/star-dns-changer
private void serviceStopped() {
startButton.setText(R.string.start);
startButton.setBackgroundResource(R.drawable.button);
firstDnsEdit.setEnabled(true);
secondDnsEdit.setEnabled(true);
firstDnsEdit.setText("");
secondDnsEdit.setText("");
chooseButton.setEnabled(true);
chooseButton.setText(R.string.choose_dns_server);
chooseButton.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
代码示例来源:origin: iQueSoft/iQuePhoto
@Override
public void onBindViewHolder(ToolsAdapter.ViewHolder holder, int position) {
final Tool tool = mToolsList.get(position);
holder.button.setText(mContext.getResources().getString(tool.getTitle()));
holder.button.setCompoundDrawablesWithIntrinsicBounds(null,
ResourcesCompat.getDrawable(mContext.getResources(), tool.getIcon(), null),
null, null);
holder.button.setOnClickListener(view -> mOnToolsClickListener.onClick(tool));
}
代码示例来源:origin: googlesamples/android-WatchFace
public void setIcon(int resourceId) {
Context context = mAppearanceButton.getContext();
mAppearanceButton.setCompoundDrawablesWithIntrinsicBounds(
context.getDrawable(resourceId), null, null, null);
}
代码示例来源:origin: algolia/instantsearch-android-examples
private void toggleArrow(Button b, boolean isUp) {
final Drawable[] currentDrawables = b.getCompoundDrawables();
b.setCompoundDrawablesWithIntrinsicBounds(currentDrawables[0], currentDrawables[1], getArrowDrawable(isUp), currentDrawables[3]);
}
代码示例来源:origin: googlesamples/android-WatchFace
public void setIcon(int resourceId) {
Context context = mBackgroundComplicationButton.getContext();
mBackgroundComplicationButton.setCompoundDrawablesWithIntrinsicBounds(
context.getDrawable(resourceId), null, null, null);
}
代码示例来源:origin: mooshim/Mooshimeter-AndroidApp
void updateScanningButton(boolean scanning) {
if (mBtnScan == null)
return; // UI not ready
if (scanning) {
// Indicate that scanning has started
mBtnScan.setText("Stop");
mBtnScan.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_cancel, 0);
mStatus.setTextAppearance(this, R.style.statusStyle_Busy);
mStatus.setText("Scanning...");
} else {
// Indicate that scanning has stopped
mStatus.setTextAppearance(this, R.style.statusStyle_Success);
mBtnScan.setText("Scan");
mBtnScan.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh, 0);
refreshAllMeterTiles();
}
if(getNDevices() == 0) {
mStatus.setText("No devices found");
}
}
代码示例来源:origin: iQueSoft/iQuePhoto
@Override
public void onBindViewHolder(AdjustAdapter.ViewHolder holder, int position) {
final Adjust adjust = mAdjustList.get(position);
holder.button.setText(mContext.getText(adjust.getTitle()));
holder.button.setCompoundDrawablesWithIntrinsicBounds(null,
ResourcesCompat.getDrawable(mContext.getResources(), adjust.getIcon(), null),
null, null);
holder.button.setOnClickListener(view -> mOnAdjustClickListener.onAdjustClick(adjust));
}
代码示例来源:origin: huangfangyi/YiChat
private View getBottomView(final int index, int drawableRes) {
View view = getLayoutInflater().inflate(R.layout.widget_main_button, null);
Button button = (Button) view.findViewById(R.id.button);
button.setCompoundDrawablesWithIntrinsicBounds(0, drawableRes, 0, 0);
// button.setCompoundDrawables(null, dr, null, null);
button.setText(mTitles[index]);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (tabs[index] != null) {
tabs[index].select();
}
}
});
if (isCompatible(Build.VERSION_CODES.LOLLIPOP)) {
button.setStateListAnimator(null);
}
TextView textView = (TextView) view.findViewById(R.id.unread_msg_number);
if (index == 0) {
unreadLabel = textView;
} else if (index == 1) {
unreadInvitionLable = textView;
}else if(index == 2){
unreadFriendLable= textView;
}
return view;
}
代码示例来源:origin: YiChat/android_YiChat_Lite
private View getBottomView(final int index, int drawableRes) {
View view = getLayoutInflater().inflate(R.layout.widget_main_button, null);
Button button = (Button) view.findViewById(R.id.button);
button.setCompoundDrawablesWithIntrinsicBounds(0, drawableRes, 0, 0);
// button.setCompoundDrawables(null, dr, null, null);
button.setText(mTitles[index]);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (tabs[index] != null) {
tabs[index].select();
}
}
});
if (isCompatible(Build.VERSION_CODES.LOLLIPOP)) {
button.setStateListAnimator(null);
}
TextView textView = (TextView) view.findViewById(R.id.unread_msg_number);
if (index == 0) {
unreadLabel = textView;
} else if (index == 1) {
unreadInvitionLable = textView;
}
return view;
}
代码示例来源:origin: MCMrARM/revolution-irc
Drawable d = AppCompatResources.getDrawable(itemView.getContext(), R.drawable.ic_delete).mutate();
DrawableCompat.setTint(d, deleteButton.getTextColors().getDefaultColor());
deleteButton.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
代码示例来源:origin: ywwynm/EverythingDone
@Override
public void onBindViewHolder(BaseViewHolder viewHolder, int position) {
if (mType == Def.PickerType.COLOR_HAVE_ALL) {
if (position == 0) {
AllColorViewHolder holder = (AllColorViewHolder) viewHolder;
if (mPickedPosition == 0) {
holder.bt.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.ic_checkbox_checked, 0, 0, 0);
holder.bt.setContentDescription(
mActivity.getString(R.string.cd_picked) + holder.bt.getText() + ",");
} else {
holder.bt.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.ic_checkbox_unchecked, 0, 0, 0);
holder.bt.setContentDescription(
mActivity.getString(R.string.cd_unpicked) + holder.bt.getText() + ",");
}
holder.bt.setClickable(mPickedPosition != 0);
} else {
setFab(viewHolder, position);
}
} else if (mType == Def.PickerType.COLOR_NO_ALL) {
setFab(viewHolder, position);
}
}
代码示例来源:origin: jruesga/rview
@BindingAdapter({"srcDrawable"})
public static void setButtonResource(Button button, int resource) {
final Context ctx = button.getContext();
Drawable drawable = null;
if (resource != 0) {
drawable = ContextCompat.getDrawable(ctx, resource);
}
button.setCompoundDrawablesWithIntrinsicBounds(
button.getId() == R.id.page_action_back ? drawable : null,
null,
button.getId() == R.id.page_action_forward ? drawable : null,
null);
}
}
内容来源于网络,如有侵权,请联系作者删除!