Example usage for android.view View TEXT_ALIGNMENT_VIEW_END

List of usage examples for android.view View TEXT_ALIGNMENT_VIEW_END

Introduction

In this page you can find the example usage for android.view View TEXT_ALIGNMENT_VIEW_END.

Prototype

int TEXT_ALIGNMENT_VIEW_END

To view the source code for android.view View TEXT_ALIGNMENT_VIEW_END.

Click Source Link

Document

Align to the end of the view, which is ALIGN_RIGHT if the view’s resolved layoutDirection is LTR, and ALIGN_LEFT otherwise.

Usage

From source file:com.facebook.litho.widget.TextSpec.java

private static Alignment getAlignment(int viewTextAlignment, int gravity) {
    final Alignment alignment;
    switch (viewTextAlignment) {
    case View.TEXT_ALIGNMENT_GRAVITY:
        alignment = getAlignment(gravity);
        break;/* w w  w  . ja va 2s  .  c om*/
    case View.TEXT_ALIGNMENT_TEXT_START:
        alignment = ALIGN_NORMAL;
        break;
    case View.TEXT_ALIGNMENT_TEXT_END:
        alignment = ALIGN_OPPOSITE;
        break;
    case View.TEXT_ALIGNMENT_CENTER:
        alignment = ALIGN_CENTER;
        break;
    case View.TEXT_ALIGNMENT_VIEW_START: // unsupported, default to normal
        alignment = ALIGN_NORMAL;
        break;
    case View.TEXT_ALIGNMENT_VIEW_END: // unsupported, default to opposite
        alignment = ALIGN_OPPOSITE;
        break;
    case View.TEXT_ALIGNMENT_INHERIT: // unsupported, default to gravity
        alignment = getAlignment(gravity);
        break;
    default:
        alignment = textAlignment;
        break;
    }
    return alignment;
}

From source file:com.android.incallui.CallCardFragment.java

/**
 * Sets the primary caller information.//  w  ww.  j a v  a 2  s. c o  m
 *
 * @param number The caller phone number.
 * @param name The caller name.
 * @param nameIsNumber {@code true} if the name should be shown in place of the phone number.
 * @param label The label.
 * @param photo The contact photo drawable.
 * @param isSipCall {@code true} if this is a SIP call.
 * @param isContactPhotoShown {@code true} if the contact photo should be shown (it will be
 *      updated even if it is not shown).
 * @param isWorkCall Whether the call is placed through a work phone account or caller is a work
      contact.
 */
@Override
public void setPrimary(String number, String name, boolean nameIsNumber, String label, Drawable photo,
        boolean isSipCall, boolean isContactPhotoShown, boolean isWorkCall) {
    Log.d(this, "Setting primary call");
    // set the name field.
    setPrimaryName(name, nameIsNumber);

    if (TextUtils.isEmpty(number) && TextUtils.isEmpty(label)) {
        mCallNumberAndLabel.setVisibility(View.GONE);
        mElapsedTime.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
    } else {
        mCallNumberAndLabel.setVisibility(View.VISIBLE);
        mElapsedTime.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_END);
    }

    setPrimaryPhoneNumber(number);

    // Set the label (Mobile, Work, etc)
    setPrimaryLabel(label);

    showInternetCallLabel(isSipCall);

    setDrawableToImageViews(photo);
    showImageView(mPhotoLarge, isContactPhotoShown);
    showImageView(mWorkProfileIcon, isWorkCall);
}

From source file:com.tct.mail.browse.ConversationItemView.java

public ConversationItemView(Context context, String account) {
    super(context);
    Utils.traceBeginSection("CIVC constructor");
    setClickable(true);/*from   www .  j  a  va2  s . co m*/
    setLongClickable(true);
    mContext = context.getApplicationContext();
    final Resources res = mContext.getResources();
    mTabletDevice = Utils.useTabletUI(res);
    mListCollapsible = res.getBoolean(R.bool.list_collapsible);
    mAccount = account;

    getItemViewResources(mContext);

    final int layoutDir = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault());

    mSendersTextView = new TextView(mContext);
    mSendersTextView.setIncludeFontPadding(false);

    mSubjectTextView = new TextView(mContext);
    mSubjectTextView.setEllipsize(TextUtils.TruncateAt.END);
    mSubjectTextView.setSingleLine(); // allow partial words to be elided
    mSubjectTextView.setIncludeFontPadding(false);
    ViewCompat.setLayoutDirection(mSubjectTextView, layoutDir);
    //AM: peng-zhang 2015-02-15 EMAIL BUGFIX_932279 MOD_S
    //ViewUtils.setTextAlignment(mSubjectTextView, View.TEXT_ALIGNMENT_VIEW_START);
    if (0 == layoutDir) {
        ViewUtils.setTextAlignment(mSubjectTextView, View.TEXT_ALIGNMENT_VIEW_START);
    } else if (1 == layoutDir) {
        ViewUtils.setTextAlignment(mSubjectTextView, View.TEXT_ALIGNMENT_VIEW_END);
    }
    //AM: peng-zhang 2015-02-15 EMAIL BUGFIX_932279 MOD_E
    mSnippetTextView = new TextView(mContext);
    mSnippetTextView.setEllipsize(TextUtils.TruncateAt.END);
    mSnippetTextView.setSingleLine(); // allow partial words to be elided
    mSnippetTextView.setIncludeFontPadding(false);
    mSnippetTextView.setTypeface(SANS_SERIF_LIGHT);
    mSnippetTextView.setTextColor(getResources().getColor(R.color.snippet_text_color));
    ViewCompat.setLayoutDirection(mSnippetTextView, layoutDir);
    //AM: peng-zhang 2015-02-16 EMAIL BUGFIX_932279 MOD_S
    //ViewUtils.setTextAlignment(mSnippetTextView, View.TEXT_ALIGNMENT_VIEW_START);
    if (0 == layoutDir) {
        ViewUtils.setTextAlignment(mSnippetTextView, View.TEXT_ALIGNMENT_VIEW_START);
    } else if (1 == layoutDir) {
        ViewUtils.setTextAlignment(mSnippetTextView, View.TEXT_ALIGNMENT_VIEW_END);
    }
    //AM: peng-zhang 2015-02-16 EMAIL BUGFIX_932279 MOD_E
    mSendersImageView = new CheckableContactFlipDrawable(res, sCabAnimationDuration);
    mSendersImageView.setCallback(this);
    // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_S
    mStatusTextView = new TextView(mContext);
    mStatusTextView.setIncludeFontPadding(false);
    mStatusTextView.setTextColor(getResources().getColor(R.color.status_text_color));
    ViewCompat.setLayoutDirection(mStatusTextView, layoutDir);
    // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_E
    Utils.traceEndSection();
}

From source file:plugin.google.maps.GoogleMaps.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override// ww  w.  j a v a2 s  .co  m
public View getInfoContents(Marker marker) {
    String title = marker.getTitle();
    String snippet = marker.getSnippet();
    if ((title == null) && (snippet == null)) {
        return null;
    }

    JSONObject properties = null;
    JSONObject styles = null;
    String propertyId = "marker_property_" + marker.getId();
    PluginEntry pluginEntry = this.plugins.get("Marker");
    PluginMarker pluginMarker = (PluginMarker) pluginEntry.plugin;
    if (pluginMarker.objects.containsKey(propertyId)) {
        properties = (JSONObject) pluginMarker.objects.get(propertyId);

        if (properties.has("styles")) {
            try {
                styles = (JSONObject) properties.getJSONObject("styles");
            } catch (JSONException e) {
            }
        }
    }

    // Linear layout
    LinearLayout windowLayer = new LinearLayout(activity);
    windowLayer.setPadding(3, 3, 3, 3);
    windowLayer.setOrientation(LinearLayout.VERTICAL);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER;
    windowLayer.setLayoutParams(layoutParams);

    //----------------------------------------
    // text-align = left | center | right
    //----------------------------------------
    int gravity = Gravity.LEFT;
    int textAlignment = View.TEXT_ALIGNMENT_GRAVITY;

    if (styles != null) {
        try {
            String textAlignValue = styles.getString("text-align");

            switch (TEXT_STYLE_ALIGNMENTS.valueOf(textAlignValue)) {
            case left:
                gravity = Gravity.LEFT;
                textAlignment = View.TEXT_ALIGNMENT_GRAVITY;
                break;
            case center:
                gravity = Gravity.CENTER;
                textAlignment = View.TEXT_ALIGNMENT_CENTER;
                break;
            case right:
                gravity = Gravity.RIGHT;
                textAlignment = View.TEXT_ALIGNMENT_VIEW_END;
                break;
            }

        } catch (Exception e) {
        }
    }

    if (title != null) {
        if (title.indexOf("data:image/") > -1 && title.indexOf(";base64,") > -1) {
            String[] tmp = title.split(",");
            Bitmap image = PluginUtil.getBitmapFromBase64encodedImage(tmp[1]);
            image = PluginUtil.scaleBitmapForDevice(image);
            ImageView imageView = new ImageView(this.cordova.getActivity());
            imageView.setImageBitmap(image);
            windowLayer.addView(imageView);
        } else {
            TextView textView = new TextView(this.cordova.getActivity());
            textView.setText(title);
            textView.setSingleLine(false);

            int titleColor = Color.BLACK;
            if (styles != null && styles.has("color")) {
                try {
                    titleColor = PluginUtil.parsePluginColor(styles.getJSONArray("color"));
                } catch (JSONException e) {
                }
            }
            textView.setTextColor(titleColor);
            textView.setGravity(gravity);
            if (VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                textView.setTextAlignment(textAlignment);
            }

            //----------------------------------------
            // font-style = normal | italic
            // font-weight = normal | bold
            //----------------------------------------
            int fontStyle = Typeface.NORMAL;
            if (styles != null) {
                try {
                    if ("italic".equals(styles.getString("font-style"))) {
                        fontStyle = Typeface.ITALIC;
                    }
                } catch (JSONException e) {
                }
                try {
                    if ("bold".equals(styles.getString("font-weight"))) {
                        fontStyle = fontStyle | Typeface.BOLD;
                    }
                } catch (JSONException e) {
                }
            }
            textView.setTypeface(Typeface.DEFAULT, fontStyle);

            windowLayer.addView(textView);
        }
    }
    if (snippet != null) {
        //snippet = snippet.replaceAll("\n", "");
        TextView textView2 = new TextView(this.cordova.getActivity());
        textView2.setText(snippet);
        textView2.setTextColor(Color.GRAY);
        textView2.setTextSize((textView2.getTextSize() / 6 * 5) / density);
        textView2.setGravity(gravity);
        if (VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            textView2.setTextAlignment(textAlignment);
        }

        windowLayer.addView(textView2);
    }
    return windowLayer;
}