static void setTextDirection(TextView number, int textDirection) { number.setTextDirection(textDirection); } }
private TextView createTextView(float textSize, int textColor) { TextView textView = new TextView(getContext()); textView.setTypeface(this.mTypeface); textView.setTextSize(0, textSize); textView.setTextColor(textColor); textView.setEllipsize(TruncateAt.END); textView.setTextDirection(5); return textView; }
textViewFileName.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); textViewFileName.setTextDirection(View.TEXT_DIRECTION_LTR); textViewFileInfo.setTextDirection(View.TEXT_DIRECTION_LOCALE);
Configuration config = context.getResources().getConfiguration(); if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { textView.setTextDirection(View.TEXT_DIRECTION_RTL);
/** * Sets phone number for a list item. This takes care of number highlighting if the highlight * mask exists. */ public void setPhoneNumber(String text, String countryIso) { if (text == null) { if (mDataView != null) { mDataView.setVisibility(View.GONE); } } else { getDataView(); // TODO: Format number using PhoneNumberUtils.formatNumber before assigning it to // mDataView. Make sure that determination of the highlight sequences are done only // after number formatting. // Sets phone number texts for display after highlighting it, if applicable. // CharSequence textToSet = text; final SpannableString textToSet = new SpannableString(text); if (mNumberHighlightSequence.size() != 0) { final HighlightSequence highlightSequence = mNumberHighlightSequence.get(0); mTextHighlighter.applyMaskingHighlight(textToSet, highlightSequence.start, highlightSequence.end); } setMarqueeText(mDataView, textToSet); mDataView.setVisibility(VISIBLE); // We have a phone number as "mDataView" so make it always LTR and VIEW_START mDataView.setTextDirection(View.TEXT_DIRECTION_LTR); mDataView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); } }
nameText = displayNumber; views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR); } else { nameText = details.getPreferredName();
public void setDisplayName(CharSequence name) { if (!TextUtils.isEmpty(name)) { // Chooses the available highlighting method for highlighting. if (mHighlightedPrefix != null) { name = mTextHighlighter.applyPrefixHighlight(name, mHighlightedPrefix); } else if (mNameHighlightSequence.size() != 0) { final SpannableString spannableName = new SpannableString(name); for (HighlightSequence highlightSequence : mNameHighlightSequence) { mTextHighlighter.applyMaskingHighlight(spannableName, highlightSequence.start, highlightSequence.end); } name = spannableName; } } else { name = mUnknownNameText; } setMarqueeText(getNameTextView(), name); if (ContactDisplayUtils.isPossiblePhoneNumber(name)) { // Give the text-to-speech engine a hint that it's a phone number mNameTextView.setTextDirection(View.TEXT_DIRECTION_LTR); mNameTextView.setContentDescription( PhoneNumberUtilsCompat.createTtsSpannable(name.toString())); } else { // Remove span tags of highlighting for talkback to avoid reading highlighting and rest // of the name into two separate parts. mNameTextView.setContentDescription(name.toString()); } }