Java Code Examples for android.widget.Button.setCompoundDrawablesWithIntrinsicBounds()

The following are Jave code examples for showing how to use setCompoundDrawablesWithIntrinsicBounds() of the android.widget.Button class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: NoticeDog   File: OverlayNotificationBarView.java   Source Code and License Vote up 6 votes
private void setButton(Button button, Message message, int index) {
    List<Action> actions = message.getActions();
    if (index >= actions.size()) {
        button.setVisibility(View.GONE);
        return;
    }
    Action action = (Action) actions.get(index);
    button.setOnClickListener(null);
    button.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
    button.setVisibility(View.VISIBLE);
    Drawable icon = getActionIcon(message.getAppId(), action.icon);
    icon.setColorFilter(new LightingColorFilter(ViewCompat.MEASURED_STATE_MASK, 6914181));
    button.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null);
    button.setText(action.title);
}
 
Example 2
Project: DMS   File: MealFragment.java   Source Code and License Vote up 5 votes
/**
 * change to collapse image of button and display meal information
 *
 * @param when Integer constant of meal time to collapse
 */
private void collapse(int when) {
    TextView textView = null;
    Button button = null;
    String mealMenu = null;

    switch (when) {
        case BREAKFAST:
            textView = mBreakfastTV;
            button = mBreakfastExpandBtn;
            if (mSelectedDayMeal != null) mealMenu = mSelectedDayMeal.getBreakfast();
            break;
        case LUNCH:
            textView = mLunchTV;
            button = mLunchExpandBtn;
            if (mSelectedDayMeal != null) mealMenu = mSelectedDayMeal.getLunch();
            break;
        case DINNER:
            textView = mDinnerTV;
            button = mDinnerExpandBtn;
            if (mSelectedDayMeal != null) mealMenu = mSelectedDayMeal.getDinner();
            break;
        default:
            break;
    }

    textView.setText(mealMenu);
    button.setText(R.string.meal_allergy);

    Drawable moreDrawable =
            ContextCompat.getDrawable(getContext(), R.drawable.ic_expand_more_white_18dp);
    button.setCompoundDrawablesWithIntrinsicBounds(null, null, moreDrawable, null);

    button.setSelected(false);
}
 
Example 3
Project: DMS   File: MealFragment.java   Source Code and License Vote up 5 votes
/**
 * change to expand image of button and display allergy information
 *
 * @param when Integer constant of meal time to expand
 */
private void expand(int when) {
    TextView textView = null;
    Button button = null;
    String mealAllergy = null;

    switch (when) {
        case BREAKFAST:
            textView = mBreakfastTV;
            button = mBreakfastExpandBtn;
            if (mSelectedDayMeal != null) mealAllergy = mSelectedDayMeal.getBreakfastAllergy();
            break;
        case LUNCH:
            textView = mLunchTV;
            button = mLunchExpandBtn;
            if (mSelectedDayMeal != null) mealAllergy = mSelectedDayMeal.getLunchAllergy();
            break;
        case DINNER:
            textView = mDinnerTV;
            button = mDinnerExpandBtn;
            if (mSelectedDayMeal != null) mealAllergy = mSelectedDayMeal.getDinnerAllergy();
            break;
        default:
            break;
    }

    textView.setText(mealAllergy);
    button.setText(R.string.meal_meal);

    Drawable lessDrawable =
            ContextCompat.getDrawable(getContext(), R.drawable.ic_expand_less_white_18dp);
    lessDrawable.setColorFilter(
            ContextCompat.getColor(getContext(), R.color.colorPrimary), PorterDuff.Mode.MULTIPLY);
    button.setCompoundDrawablesWithIntrinsicBounds(null, null, lessDrawable, null);

    button.setSelected(true);
}
 
Example 4
Project: SmartMath   File: ActivityCfgKeyPad.java   Source Code and License Vote up 5 votes
public void setBtnIcons(int nScreenSizeCategory, int nScreenOrientation)	{
   	Button btnPrevInputPad = (Button)findViewById(R.id.btnPrevInputPad);
   	Button btnNextInputPad = (Button)findViewById(R.id.btnNextInputPad);
	if (nScreenSizeCategory >= Configuration.SCREENLAYOUT_SIZE_LARGE + 1)	{	//	xlarge size
    	// Configuration.SCREENLAYOUT_SIZE_XLARGE is not supported until Android 9, this is to ensure
    	// compatibility with Android 7.
    	btnPrevInputPad.setCompoundDrawablesWithIntrinsicBounds(R.drawable.toleft_land_large, 0, 0, 0);
    	btnNextInputPad.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.toright_land_large, 0);
    } else	{	// normal size or undefined size
    	btnPrevInputPad.setCompoundDrawablesWithIntrinsicBounds(R.drawable.toleft_land, 0, 0, 0);
    	btnNextInputPad.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.toright_land, 0);
    }
}
 
Example 5
Project: microbit   File: ProjectAdapter.java   Source Code and License Vote up 4 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    Project project = mProjects.get(position);
    if(convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(MBApp.getApp());
        convertView = inflater.inflate(R.layout.project_items, null);
    }

    Button appNameButton = (Button) convertView.findViewById(R.id.appNameButton);
    appNameButton.setTypeface(MBApp.getApp().getRobotoTypeface());

    ExtendedEditText appNameEdit = (ExtendedEditText) convertView.findViewById(R.id.appNameEdit);
    appNameEdit.setTypeface(MBApp.getApp().getRobotoTypeface());

    LinearLayout actionBarLayout = (LinearLayout) convertView.findViewById(R.id.actionBarForProgram);
    if(actionBarLayout != null) {
        if(project.actionBarExpanded) {
            actionBarLayout.setVisibility(View.VISIBLE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_down), null);
        } else {
            actionBarLayout.setVisibility(View.GONE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_left), null);
        }
    }

    appNameButton.setText(project.name);
    appNameButton.setTag(R.id.positionId, position);
    appNameButton.setTag(R.id.textEdit, appNameEdit);
    appNameButton.setOnClickListener(appNameClickListener);
    appNameButton.setOnLongClickListener(appNameLongClickListener);

    appNameEdit.setTag(R.id.positionId, position);
    appNameEdit.setTag(R.id.editbutton, appNameButton);
    appNameEdit.setOnEditorActionListener(editorOnActionListener);
    appNameEdit.setFilters(new InputFilter[]{renameFilter});

    if(project.inEditMode) {
        appNameEdit.setVisibility(View.VISIBLE);

        appNameEdit.setText(project.name);
        appNameEdit.setSelection(project.name.length());
        appNameEdit.requestFocus();
        appNameButton.setVisibility(View.INVISIBLE);

    } else {
        appNameEdit.setVisibility(View.INVISIBLE);
        appNameButton.setVisibility(View.VISIBLE);
        //dismissKeyBoard(appNameEdit, false);
    }

    //appNameEdit.setOnClickListener(appNameClickListener);

    TextView flashBtnText = (TextView) convertView.findViewById(R.id.project_item_text);
    flashBtnText.setTypeface(MBApp.getApp().getRobotoTypeface());
    LinearLayout sendBtnLayout = (LinearLayout) convertView.findViewById(R.id.sendBtn);
    sendBtnLayout.setTag(position);
    sendBtnLayout.setOnClickListener(sendBtnClickListener);

    ImageButton deleteBtn = (ImageButton) convertView.findViewById(R.id.deleteBtn);
    deleteBtn.setTag(position);
    deleteBtn.setOnClickListener(deleteBtnClickListener);
    deleteBtn.setEnabled(true);


    Drawable myIcon;
    if(project.runStatus) {
        flashBtnText.setText("");
        myIcon = convertView.getResources().getDrawable(R.drawable.green_btn);
    } else {
        flashBtnText.setText(R.string.flash);
        myIcon = convertView.getResources().getDrawable(R.drawable.blue_btn);
    }
    sendBtnLayout.setBackground(myIcon);

    sendBtnLayout.setClickable(true);
    return convertView;
}