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.
+ Save this method
Example 1
Project: FCM-for-Mojo   File: ServerStatusPreference.java   View Source Code Vote up 5 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(android.R.id.text1);

        if (icon != null) {
            icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
            status.setCompoundDrawablesRelative(icon, null, null, null);
        } else {
            status.setCompoundDrawablesRelative(null, null, null, null);
        }
        status.setText(text);
        statusCard.setCardBackgroundColor(color);
    }
}
 
Example 2
Project: chromium-net-for-android   File: ApiCompatibilityUtils.java   View Source Code 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) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1) {
        // 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: http://crbug.com/368196 and http://crbug.com/361709
        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: TextViewCompatJbMr2.java   View Source Code 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);
}