TextView setCompoundDrawablesWithIntrinsicBounds - 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 setCompoundDrawablesWithIntrinsicBounds method.

This code example shows how to use the following methods:setLayoutParams, setCompoundDrawablesWithIntrinsicBounds, setGravity, setPadding, setText
			} catch (NameNotFoundException e) {
				return 0; 
			} 
        } 
        public TextView getGenericView() {
            TextView textView = new TextView(ActivityPickerActivity.this);
            textView.setLayoutParams(lpGroup);
            textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
            textView.setPadding(leftPadding, 0, 0, 0);
            return textView;
        } 
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                View convertView, ViewGroup parent) {
            TextView textView = getGenericView();
            ActivityInfo activity=getChild(groupPosition, childPosition);
            if(activity!=null){
	            String name=activity.name.replace(activity.packageName, "");
	        	textView.setText(activity.loadLabel(mPackageManager)+"("+name+")");
	        	textView.setLayoutParams(lpChild);
            } 

8
CodeRank
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) {
        button.setText(buttonDef.getText());
 
        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);
            button.setCompoundDrawablePadding(0);
        } 
 
        applyViewDef(button, buttonDef);
    } 
 
    public static void applyButtonDef(@Nonnull ImageButton imageButton, @Nonnull ButtonDef buttonDef) {
7
CodeRank
This code example shows how to use the following methods:setTag, setCompoundDrawablesWithIntrinsicBounds, setText
	 */ 
	@Override 
	public void bindView(View view, Context context, Cursor cursor)
	{ 
		TextView textView = (TextView)view;
		textView.setText(cursor.getString(1));
		textView.setCompoundDrawablesWithIntrinsicBounds(mEditable ? mExpander : null, null, null, null);
		textView.setTag(cursor.getLong(3));
	} 
 
	/** 
	 * Generate a new view. 
	 */ 
	@Override 
	public View newView(Context context, Cursor cursor, ViewGroup parent)
	{ 
		return mInflater.inflate(R.layout.playlist_row, null);
	} 
 
	/** 
7
CodeRank
This code example shows how to use the following methods:getCompoundDrawablePadding, setCompoundDrawablesWithIntrinsicBounds, setPadding
        } 
    } 
 
    private void setTitleIcon(int id) {
        if (id == 0) {
            mTitle.setPadding(mTitle.getCompoundDrawablePadding(), 0, 0, 0);
        } else { 
            mTitle.setPadding(0, 0, 0, 0);
        } 
        mTitle.setCompoundDrawablesWithIntrinsicBounds(id, 0, 0, 0);
    } 
 
    protected boolean isHighlighted() { 
        return mHighlighted;
    } 
 
    protected void setWebView(Tab tab) {
        mTab = tab;
        setTitle(); 
        Bitmap image = tab.getScreenshot();
7
CodeRank
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);
		view.setCompoundDrawablePadding(10);
		 
		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;
	} 
 
	@Override 
6
CodeRank
This code example shows how to use the following methods:setCompoundDrawablesWithIntrinsicBounds
 
    private void setImage(View view, Drawable drawable, boolean crossfade) {
        if (view instanceof TextView) {
            // Cross-fading is not implemented for TextView since it's not in use.  It would be easy to add it, though. 
            TextView textView = (TextView) view;
            textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
        } else if (view instanceof ImageView) {
            ImageView imageView = (ImageView) view;
            if (crossfade) {
 
                Drawable existingDrawable = imageView.getDrawable();
                if (existingDrawable == null) {
                    Bitmap emptyImage = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
                    existingDrawable = new BitmapDrawable(emptyImage);
                } 
 
                Drawable[] layers = new Drawable[]{existingDrawable, drawable};
 
                TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
                imageView.setImageDrawable(transitionDrawable);
6
CodeRank
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);
                return; 
            } 
 
            Drawable d = null;
            Resources res = mContext.getResources();
            // Set the padding between the icon and the text. 
            t.setCompoundDrawablePadding(mIconTextPadding);
            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 

5
CodeRank
This code example shows how to use the following methods:setCompoundDrawablesWithIntrinsicBounds, setText
     * Override this if you have other work to do when the volume changes (for 
     * example, vibrating, playing a sound, etc.). Make sure to call through to 
     * the superclass implementation. 
     */ 
    protected void onBrightnessChanged(final int value, final int max) {
        mText.setText(Integer.toString(Math.round(value * 100.0f / max)) + "%");
        mText.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null);
	int progress = (int) (Math.round(value * 100.0f / max));
	mBrightProg.setProgress(progress);
        mToast.setView(mView);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.setGravity(Gravity.TOP, 0, 0);
        mToast.show();
    } 
 
    @Override 
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case MSG_BRIGHTNESS_CHANGED: {
                onBrightnessChanged(msg.arg1, msg.arg2);
5
CodeRank
This code example shows how to use the following methods:setCompoundDrawablesWithIntrinsicBounds, setText
     * Override this if you have other work to do when the volume changes (for 
     * example, vibrating, playing a sound, etc.). Make sure to call through to 
     * the superclass implementation. 
     */ 
    protected void onBrightnessChanged(final int value, final int max) {
        mText.setText(Integer.toString(Math.round(value * 100.0f / max)) + "%");
        mText.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null);
	int progress = (int) (Math.round(value * 100.0f / max));
	mBrightProg.setProgress(progress);
        mToast.setView(mView);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.setGravity(Gravity.TOP, 0, 0);
        mToast.show();
    } 
 
    @Override 
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case MSG_BRIGHTNESS_CHANGED: {
                onBrightnessChanged(msg.arg1, msg.arg2);
5
CodeRank
This code example shows how to use the following methods:setCompoundDrawablesWithIntrinsicBounds
			bd = new BitmapDrawable(Bitmap.createScaledBitmap(icon, mFaviconSize, mFaviconSize, false));
		} else { 
			bd = null;
		} 
		 
		mTitleView.setCompoundDrawablesWithIntrinsicBounds(bd, null, null, null);
	} 
 
	@Override 
	public void setOnClickListener(OnClickListener listener) {
		mClickListener = listener;
		mTitleBar.setOnClickListener(mClickListener);
		mCloseView.setOnClickListener(mClickListener);
		if (mImage != null) {
			mImage.setOnClickListener(mClickListener);
		} 
	} 
	 
	private void updateTitle() { 
		if (mTitle != null) {
5
CodeRank

Related TextView setCompoundDrawablesWithIntrinsicBounds Questions & Answers:

setCompoundDrawablesWithIntrinsicBounds Method Overview
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
See Code Examples for other Android TextView Methods: