Java Code Examples for android.widget.CheckBox#setButtonDrawable()
The following examples show how to use
android.widget.CheckBox#setButtonDrawable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TintHelper.java From a with GNU General Public License v3.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light), ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = createTintedDrawable(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl); box.setButtonDrawable(drawable); } }
Example 2
Source File: TintHelper.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light), ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = createTintedDrawable(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl); box.setButtonDrawable(drawable); } }
Example 3
Source File: UserSelectorHolder.java From YiBo with Apache License 2.0 | 6 votes |
public UserSelectorHolder(View convertView) { if (convertView == null) { throw new IllegalArgumentException("convertView is null!"); } context = convertView.getContext(); ivProfilePicture = (ImageView) convertView.findViewById(R.id.ivProfilePicture); tvScreenName = (TextView) convertView.findViewById(R.id.tvScreenName); ivVerify = (ImageView) convertView.findViewById(R.id.ivVerify); tvImpress = (TextView) convertView.findViewById(R.id.tvImpress); cbUser = (CheckBox)convertView.findViewById(R.id.cbUser); //主题 Theme theme = ThemeUtil.createTheme(context); tvScreenName.setTextColor(theme.getColor("content")); ivVerify.setImageDrawable(theme.getDrawable("icon_verification")); tvImpress.setTextColor(theme.getColor("remark")); cbUser.setButtonDrawable(theme.getDrawable("selector_checkbox")); reset(); }
Example 4
Source File: MDTintHelper.java From NewsMe with Apache License 2.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{ ThemeHelper.resolveColor(box.getContext(), R.attr.colorControlNormal), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
Example 5
Source File: MDTintHelper.java From talk-android with MIT License | 6 votes |
@SuppressLint("NewApi") public static void setTint(CheckBox box, int color) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{ DialogUtils.resolveColor(box.getContext(), R.attr.colorControlNormal), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
Example 6
Source File: TintHelper.java From APlayer with GNU General Public License v3.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light), ContextCompat.getColor(box.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = createTintedDrawable( ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl); box.setButtonDrawable(drawable); } }
Example 7
Source File: EmTintUtils.java From AndroidTint with Apache License 2.0 | 6 votes |
public static void setTint(@NonNull CheckBox box, @ColorInt int color) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{ ThemeHelper.resolveColor(box.getContext(), R.attr.colorControlNormal), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
Example 8
Source File: Utils.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
public static void setTint(Context context, CheckBox box, int color) { if (Build.VERSION.SDK_INT >= 21) return; ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked} }, new int[]{getColor(context, R.color.grey), color}); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { box.setButtonTintList(sl); } else { Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material)); DrawableCompat.setTintList(drawable, sl); box.setButtonDrawable(drawable); } }
Example 9
Source File: AccountSelectorHolder.java From YiBo with Apache License 2.0 | 5 votes |
public AccountSelectorHolder(View convertView) { if (convertView == null) { throw new IllegalArgumentException("convertView is null!"); } ivProfilePicture = (ImageView)convertView.findViewById(R.id.ivProfileImage); tvScreenName = (TextView)convertView.findViewById(R.id.tvScreenName); tvSPName = (TextView)convertView.findViewById(R.id.tvSPName); cbAccountSelector = (CheckBox)convertView.findViewById(R.id.cbAccountSelector); //设置主题 theme = ThemeUtil.createTheme(convertView.getContext()); tvScreenName.setTextColor(theme.getColor("content")); tvSPName.setTextColor(theme.getColor("quote")); cbAccountSelector.setButtonDrawable(theme.getDrawable("selector_checkbox")); }
Example 10
Source File: MdLayoutInflaterFactory.java From android-md-core with Apache License 2.0 | 5 votes |
protected void supportCheckBox(Context context, CheckBox view, AttributeSet attrs) { if (view == null) { return; } Drawable drawable = MdVectorDrawableCompat.getFromAttribute(context, attrs, R.attr.srcCompat); if (drawable != null) { view.setButtonDrawable(drawable); } }
Example 11
Source File: AccountAdapter.java From AppCompat-Extension-Library with Apache License 2.0 | 5 votes |
private static void setupCheckBox(CheckBox checkBox) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { checkBox.setButtonDrawable(R.drawable.btn_checkbox_circle); checkBox.setBackgroundResource(R.drawable.btn_checkbox_circle_background); } else { Context context = checkBox.getContext(); AppCompatDrawableManager dm = AppCompatDrawableManager.get(); StateListDrawable button = new StateListDrawable(); button.addState(new int[]{android.R.attr.state_checked}, dm.getDrawable(context, R.drawable.ic_checkbox_circle_checked)); button.addState(new int[]{}, dm.getDrawable(context, R.drawable.ic_checkbox_circle_unchecked)); ColorStateList buttonTint = new ColorStateList(new int[][]{ // states new int[]{android.R.attr.state_checked}, new int[]{} // state_default }, new int[]{ // colors ThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated), ThemeUtils.getThemeAttrColor(context, R.attr.colorControlNormal) }); Drawable buttonCompat = DrawableCompat.wrap(button); DrawableCompat.setTintList(buttonCompat, buttonTint); checkBox.setButtonDrawable(buttonCompat); ShapeDrawable background = new ShapeDrawable(new OvalShape()); int backgroundTint = ThemeUtils.getThemeAttrColor(context, android.R.attr.colorBackground); Drawable backgroundCompat = DrawableCompat.wrap(background); DrawableCompat.setTint(backgroundCompat, backgroundTint); ViewCompatUtils.setBackground(checkBox, backgroundCompat); } }
Example 12
Source File: XLHRatingBar.java From BookReader with Apache License 2.0 | 4 votes |
private void initView() { removeAllViews(); for (int i = 0; i < countNum; i++) { CheckBox cb = new CheckBox(getContext()); LayoutParams layoutParams; if (widthAndHeight == 0) { layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); } else { layoutParams = new LayoutParams((int) widthAndHeight, (int) widthAndHeight); } if (differentSize && countNum % 2 != 0) { Log.e("xxx", layoutParams.width + ""); int index = i; if (index > countNum / 2) { index = countNum - 1 - index; } float scale = (index + 1) / (float) (countNum / 2 + 1); layoutParams.width = (int) (layoutParams.width * scale); layoutParams.height = layoutParams.width; } layoutParams.gravity = Gravity.CENTER_VERTICAL; if (i != 0 && i != countNum - 1) { layoutParams.leftMargin = (int) dividerWidth; layoutParams.rightMargin = (int) dividerWidth; } else if (i == 0) { layoutParams.rightMargin = (int) dividerWidth; } else if (i == countNum - 1) { layoutParams.leftMargin = (int) dividerWidth; } addView(cb, layoutParams); cb.setButtonDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent))); if (stateResId == -1) { stateResId = R.drawable.book_review_rating_bar_selector; } cb.setBackgroundResource(stateResId); if (i + 1 <= countSelected) { cb.setChecked(true); } cb.setEnabled(canEdit); cb.setOnClickListener(new MyClickListener(i)); } }
Example 13
Source File: SDKUtils.java From letv with Apache License 2.0 | 4 votes |
public static void setCheckBoxBackground(CheckBox mChechBox, Drawable drawable) { mChechBox.setButtonDrawable(drawable); }
Example 14
Source File: BasicActivity.java From letv with Apache License 2.0 | 4 votes |
protected void beautyCheckButton(CheckBox mCheckBox, OnCheckedChangeListener mOnCheckedChangeListener) { mCheckBox.setButtonDrawable(this.crMgmt.getCheckStatusDrawable("uac_showpwd_normal", "uac_showpwd_press", false)); mCheckBox.setOnCheckedChangeListener(mOnCheckedChangeListener); }
Example 15
Source File: AccountSelectorListAdapter.java From YiBo with Apache License 2.0 | 4 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { AccountSelectorHolder holder = null; if (convertView == null) { convertView = inflater.inflate(R.layout.list_item_account_selector, null); holder = new AccountSelectorHolder(convertView); convertView.setTag(holder); } else { holder = (AccountSelectorHolder)convertView.getTag(); } final LocalAccount account = (LocalAccount)getItem(position); if (account == null) { return convertView; } holder.reset(account.getServiceProvider()); String profileImageUrl = account.getUser().getProfileImageUrl(); if (StringUtil.isNotEmpty(profileImageUrl)) { new ImageLoad4HeadTask(holder.ivProfilePicture, profileImageUrl, true).execute(); } CheckBox cbAccountSelector = holder.cbAccountSelector; if (mode == SelectMode.Single) { cbAccountSelector.setButtonDrawable(holder.theme.getDrawable("selector_checkbox_group")); } else { cbAccountSelector.setButtonDrawable(holder.theme.getDrawable("selector_checkbox")); } if (listSelectedAccount.contains(account)) { cbAccountSelector.setChecked(true); } else { cbAccountSelector.setChecked(false); } holder.tvScreenName.setText(account.getUser().getScreenName()); String snNameText = account.getServiceProvider().getSpName(); holder.tvSPName.setText(snNameText); return convertView; }
Example 16
Source File: XLHRatingBar.java From fangzhuishushenqi with Apache License 2.0 | 4 votes |
private void initView() { removeAllViews(); for (int i = 0; i < countNum; i++) { CheckBox cb = new CheckBox(getContext()); LayoutParams layoutParams; if (widthAndHeight == 0) { layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); } else { layoutParams = new LayoutParams((int) widthAndHeight, (int) widthAndHeight); } if (differentSize && countNum % 2 != 0) { Log.e("xxx", layoutParams.width + ""); int index = i; if (index > countNum / 2) { index = countNum - 1 - index; } float scale = (index + 1) / (float) (countNum / 2 + 1); layoutParams.width = (int) (layoutParams.width * scale); layoutParams.height = layoutParams.width; } layoutParams.gravity = Gravity.CENTER_VERTICAL; if (i != 0 && i != countNum - 1) { layoutParams.leftMargin = (int) dividerWidth; layoutParams.rightMargin = (int) dividerWidth; } else if (i == 0) { layoutParams.rightMargin = (int) dividerWidth; } else if (i == countNum - 1) { layoutParams.leftMargin = (int) dividerWidth; } addView(cb, layoutParams); cb.setButtonDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent))); if (stateResId == -1) { stateResId = R.drawable.book_review_rating_bar_selector; } cb.setBackgroundResource(stateResId); if (i + 1 <= countSelected) { cb.setChecked(true); } cb.setEnabled(canEdit); cb.setOnClickListener(new MyClickListener(i)); } }
Example 17
Source File: AddAccountActivity.java From YiBo with Apache License 2.0 | 4 votes |
private void initComponents() { LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase); ScrollView svContentPanel = (ScrollView)findViewById(R.id.svContentPanel); spServiceProvider = (Spinner) findViewById(R.id.spServiceProvider); spConfigApp = (Spinner) findViewById(R.id.spConfigApp); etUsername = (EditText) findViewById(R.id.etUsername); etPassword = (EditText) findViewById(R.id.etPassword); cbMakeDefault = (CheckBox) findViewById(R.id.cbDefault); cbFollowOffical = (CheckBox) findViewById(R.id.cbFollowOffical); cbUseProxy = (CheckBox) findViewById(R.id.cbUseApiProxy); etRestProxy = (EditText) findViewById(R.id.etRestProxy); etSearchProxy = (EditText) findViewById(R.id.etSearchProxy); btnAuthorize = (Button) findViewById(R.id.btnAuthorize); LinearLayout llOAuthIntro = (LinearLayout)findViewById(R.id.llOAuthIntro); TextView tvOAuthIntro = (TextView)findViewById(R.id.tvOAuthIntro); LinearLayout llFooterAction = (LinearLayout)findViewById(R.id.llFooterAction); ThemeUtil.setSecondaryHeader(llHeaderBase); ThemeUtil.setContentBackground(svContentPanel); spServiceProvider.setBackgroundDrawable(theme.getDrawable("selector_btn_dropdown")); spConfigApp.setBackgroundDrawable(theme.getDrawable("selector_btn_dropdown")); int padding2 = theme.dip2px(2); spServiceProvider.setPadding(padding2, padding2, padding2, padding2); spConfigApp.setPadding(padding2, padding2, padding2, padding2); int content = theme.getColor("content"); etUsername.setBackgroundDrawable(theme.getDrawable("selector_input_frame")); etUsername.setTextColor(content); etPassword.setBackgroundDrawable(theme.getDrawable("selector_input_frame")); etPassword.setTextColor(content); cbMakeDefault.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbMakeDefault.setTextColor(content); cbFollowOffical.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbFollowOffical.setTextColor(content); cbUseProxy.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbUseProxy.setTextColor(content); etRestProxy.setBackgroundDrawable(theme.getDrawable("selector_input_frame")); etRestProxy.setTextColor(content); etSearchProxy.setBackgroundDrawable(theme.getDrawable("selector_input_frame")); etSearchProxy.setTextColor(content); llOAuthIntro.setBackgroundDrawable(theme.getDrawable("bg_frame_normal")); int padding8 = theme.dip2px(8); llOAuthIntro.setPadding(padding8, padding8, padding8, padding8); tvOAuthIntro.setTextColor(theme.getColor("quote")); llFooterAction.setBackgroundDrawable(theme.getDrawable("bg_footer_action")); llFooterAction.setPadding(padding8, padding8, padding8, padding8); llFooterAction.setGravity(Gravity.CENTER); ThemeUtil.setBtnActionPositive(btnAuthorize); TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle); tvTitle.setText(R.string.title_add_account); ConfigSystemDao configDao = new ConfigSystemDao(this); Passport passport = configDao.getPassport(); if (passport != null) { isCustomKeyLevel = passport.getPointsLevel().getPoints() >= Constants.POINTS_CUSTOM_SOURCE_LEVEL ; } isCustomKeyLevel = true; // 调试用 if (isCustomKeyLevel) { } }
Example 18
Source File: EditRetweetActivity.java From YiBo with Apache License 2.0 | 4 votes |
private void initComponents() { LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase); LinearLayout llContentPanel = (LinearLayout)findViewById(R.id.llContentPanel); LinearLayout llEditText = (LinearLayout)findViewById(R.id.llEditText); MultiAutoCompleteTextView etText = (MultiAutoCompleteTextView)findViewById(R.id.etText); Button btnEmotion = (Button)this.findViewById(R.id.btnEmotion); Button btnMention = (Button)this.findViewById(R.id.btnMention); Button btnTopic = (Button)this.findViewById(R.id.btnTopic); Button btnTextCount = (Button)this.findViewById(R.id.btnTextCount); cbComment = (CheckBox) this.findViewById(R.id.cbComment); cbCommentToOrigin = (CheckBox)this.findViewById(R.id.cbCommentToOrigin); tvText = (TextView)this.findViewById(R.id.tvText); ThemeUtil.setSecondaryHeader(llHeaderBase); ThemeUtil.setContentBackground(llContentPanel); int padding6 = theme.dip2px(6); int padding8 = theme.dip2px(8); llContentPanel.setPadding(padding6, padding8, padding6, 0); llEditText.setBackgroundDrawable(theme.getDrawable("bg_input_frame_normal")); etText.setTextColor(theme.getColor("content")); btnEmotion.setBackgroundDrawable(theme.getDrawable("selector_btn_emotion")); btnMention.setBackgroundDrawable(theme.getDrawable("selector_btn_mention")); btnTopic.setBackgroundDrawable(theme.getDrawable("selector_btn_topic")); btnTextCount.setBackgroundDrawable(theme.getDrawable("selector_btn_text_count")); btnTextCount.setPadding(padding6, 0, theme.dip2px(20), 0); btnTextCount.setTextColor(theme.getColor("status_capability")); cbComment.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbComment.setTextColor(theme.getColor("content")); cbCommentToOrigin.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbCommentToOrigin.setTextColor(theme.getColor("content")); tvText.setTextColor(theme.getColor("quote")); TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle); tvTitle.setText(R.string.title_retweet); MicroBlogTextWatcher textWatcher = new MicroBlogTextWatcher(this); etText.addTextChangedListener(textWatcher); etText.setHint(R.string.hint_retweet); etText.requestFocus(); etText.setAdapter(new UserSuggestAdapter(this)); etText.setTokenizer(new EditMicroBlogTokenizer()); retweetedStatus = status; if (status.getServiceProvider() != ServiceProvider.Sohu) { if (status.getServiceProvider() == ServiceProvider.Fanfou || status.getRetweetedStatus() != null) { etText.setText( String.format( FeaturePatternUtils.getRetweetFormat(status.getServiceProvider()), FeaturePatternUtils.getRetweetSeparator(status.getServiceProvider()), status.getUser().getMentionName(), status.getText() ) ); } if (!(status.getServiceProvider() == ServiceProvider.Fanfou || status.getRetweetedStatus() == null)) { retweetedStatus = status.getRetweetedStatus(); } etText.setSelection(0); } int length = StringUtil.getLengthByByte(etText.getText().toString()); int leavings = (int) Math.floor((double) (Constants.STATUS_TEXT_MAX_LENGTH * 2 - length) / 2); btnTextCount.setText((leavings < 0 ? "-" : "") + Math.abs(leavings)); String lableComment = this.getString(R.string.label_retweet_with_comment, status.getUser().getScreenName()); cbComment.setText(lableComment); if (isComment2OriginVisible()) { String lableCommentToOrigin = this.getString( R.string.label_retweet_with_comment_to_origin, retweetedStatus.getUser().getScreenName()); cbCommentToOrigin.setText(lableCommentToOrigin); cbCommentToOrigin.setVisibility(View.VISIBLE); } String promptText = retweetedStatus.getUser().getMentionTitleName() + ":" + retweetedStatus.getText(); tvText.setText(promptText); }