Java Code Examples for android.widget.TextView.setCompoundDrawablesRelative()

The following are Jave code examples for showing how to use setCompoundDrawablesRelative() of the android.widget.TextView 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: FCM-for-Mojo   File:   Source Code and License Vote up 6 votes
private void updateStatus(CharSequence text, @ColorInt int color, Drawable icon) {
    if (mViewHolder != null) {
        CardView statusCard = (CardView) ((ViewGroup) mViewHolder.itemView).getChildAt(0);
        TextView status = statusCard.findViewById(;

        if (icon != null) {
            icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
            status.setCompoundDrawablesRelative(icon, null, null, null);
        } else {
            status.setCompoundDrawablesRelative(null, null, null, null);
Example 2
Project: chromium-net-for-android   File:   Source Code and License Vote up 5 votes
 * @see android.widget.TextView#setCompoundDrawablesRelative(Drawable, Drawable, Drawable,
 *      Drawable)
public static void setCompoundDrawablesRelative(TextView textView, Drawable start, Drawable top,
        Drawable end, Drawable bottom) {
        // On JB MR1, due to a platform bug, setCompoundDrawablesRelative() is a no-op if the
        // view has ever been measured. As a workaround, use setCompoundDrawables() directly.
        // See: and
        boolean isRtl = isLayoutRtl(textView);
        textView.setCompoundDrawables(isRtl ? end : start, top, isRtl ? start : end, bottom);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) {
        textView.setCompoundDrawablesRelative(start, top, end, bottom);
    } else {
        textView.setCompoundDrawables(start, top, end, bottom);
Example 3
Project: boohee_v5.6   File:   Source Code and License Vote up 4 votes
public static void setCompoundDrawablesRelative(@NonNull TextView textView, @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, @Nullable Drawable bottom) {
    textView.setCompoundDrawablesRelative(start, top, end, bottom);