TextView setCompoundDrawablePadding - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextView setCompoundDrawablePadding method.

This code example shows how to use the following methods:getContext, setCompoundDrawablePadding, setCompoundDrawablesWithIntrinsicBounds, setPadding, setText
        return false; 
    public static void applyButtonDef(@Nonnull Button button, @Nonnull ButtonDef buttonDef) {
        final Integer drawableResId = buttonDef.getDrawableResId();
        if ( drawableResId != null ) {
            button.setPadding(0, 0, 0, 0);
            final Drawable drawable = button.getContext().getResources().getDrawable(drawableResId);
            button.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
        applyViewDef(button, buttonDef);
    public static void applyButtonDef(@Nonnull ImageButton imageButton, @Nonnull ButtonDef buttonDef) {
This code example shows how to use the following methods:setCompoundDrawablePadding, setCompoundDrawablesWithIntrinsicBounds, setPadding, setText
	protected View createEntry(LayoutInflater inflater, int resIcon, boolean multipleChoice, ServerInfo.ResourceInfo info) {
		CheckedTextView view = (CheckedTextView) inflater.inflate(multipleChoice ?
			android.R.layout.simple_list_item_multiple_choice :
			android.R.layout.simple_list_item_single_choice, null);
		view.setPadding(10, 10, 10, 10);
		view.setCompoundDrawablesWithIntrinsicBounds(resIcon, 0, 0, 0);
		String description = info.getDescription();
		if (description == null)
			description = info.getPath();
		// FIXME escape HTML 
		view.setText(Html.fromHtml("<b>" + info.getTitle() + "</b><br/>" + description));
		return view;
This code example shows how to use the following methods:setCompoundDrawablePadding, setCompoundDrawablesWithIntrinsicBounds
            return mBlankDrawable;
        private void maybeUpdateIcon(PromptListItem item, TextView t) {
            if (item.icon == null && !item.inGroup && !item.isParent) {
                t.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
            Drawable d = null;
            Resources res = mContext.getResources();
            // Set the padding between the icon and the text. 
            if (item.icon != null) {
                // We want the icon to be of a specific size. Some do not 
                // follow this rule so we have to resize them. 
                Bitmap bitmap = ((BitmapDrawable) item.icon).getBitmap();
                d = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap, mIconSize, mIconSize, true));
            } else if (item.inGroup) {
                // We don't currently support "indenting" items with icons 


Related TextView setCompoundDrawablePadding Questions & Answers:

setCompoundDrawablePadding Method Overview
Sets the size of the padding between the compound drawables and the text.
See Code Examples for other Android TextView Methods: