Example usage for android.view View TEXT_ALIGNMENT_VIEW_START

List of usage examples for android.view View TEXT_ALIGNMENT_VIEW_START

Introduction

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

Prototype

int TEXT_ALIGNMENT_VIEW_START

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

Click Source Link

Document

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

Usage

From source file:hcm.ssj.creator.dialogs.FileDialog.java

/**
 * @param savedInstanceState Bundle/*from w ww.j  a  v  a2  s  . co m*/
 * @return Dialog
 */
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(titleMessage);
    builder.setPositiveButton(R.string.str_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            switch (type) {
            case SAVE: {
                String fileName = editText.getText().toString().trim();
                File dir1 = new File(Environment.getExternalStorageDirectory(), Util.DIR_1);
                File dir2 = new File(dir1.getPath(), Util.DIR_2);
                if (!fileName.isEmpty() && (dir2.exists() || dir2.mkdirs())) {
                    if (!fileName.endsWith(Util.SUFFIX)) {
                        fileName += Util.SUFFIX;
                    }
                    File file = new File(dir2, fileName);
                    if (isValidFileName(file) && SaveLoad.save(file)) {
                        for (Listener listener : alListeners) {
                            listener.onPositiveEvent(null);
                        }
                        return;
                    }
                }
                for (Listener listener : alListeners) {
                    listener.onNegativeEvent(new Boolean[] { false });
                }
                return;
            }
            case LOAD:
            case DELETE: {
                if (xmlFiles != null && xmlFiles.length > 0) {
                    int pos = listView.getCheckedItemPosition();
                    if (pos > AbsListView.INVALID_POSITION) {
                        if (type == Type.DELETE && xmlFiles[pos].delete()) {
                            for (Listener listener : alListeners) {
                                listener.onPositiveEvent(null);
                            }
                            return;
                        } else if (type == Type.LOAD) {
                            if (SaveLoad.load(xmlFiles[pos])) {
                                for (Listener listener : alListeners) {
                                    listener.onPositiveEvent(null);
                                }
                                return;
                            }
                        }
                        for (Listener listener : alListeners) {
                            listener.onNegativeEvent(new Boolean[] { false });
                        }
                        return;
                    }
                }
                for (Listener listener : alListeners) {
                    listener.onNegativeEvent(null);
                }
                break;
            }
            }
        }
    });
    builder.setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            for (Listener listener : alListeners) {
                listener.onNegativeEvent(null);
            }
        }
    });
    //set up the input
    switch (type) {
    case SAVE: {
        editText = new EditText(getContext());
        editText.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
        editText.setInputType(InputType.TYPE_CLASS_TEXT);
        builder.setView(editText);
        break;
    }
    case LOAD:
    case DELETE: {
        listView = new ListView(getContext());
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        File dir1 = new File(Environment.getExternalStorageDirectory(), Util.DIR_1);
        File dir2 = new File(dir1.getPath(), Util.DIR_2);
        xmlFiles = dir2.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File folder, String name) {
                return name.toLowerCase().endsWith(Util.SUFFIX);
            }
        });
        if (xmlFiles != null && xmlFiles.length > 0) {
            String[] ids = new String[xmlFiles.length];
            for (int i = 0; i < ids.length; i++) {
                ids[i] = xmlFiles[i].getName();
            }
            listView.setAdapter(
                    new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_single_choice, ids));
        } else {
            listView.setAdapter(
                    new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_single_choice));
        }
        builder.setView(listView);
        break;
    }
    }
    return builder.create();
}

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

public ConversationItemView(Context context, Account account) {
    super(context);
    Utils.traceBeginSection("CIVC constructor");
    setClickable(true);//from w w w  .java 2s .c om
    setLongClickable(true);
    mContext = context.getApplicationContext();
    final Resources res = mContext.getResources();
    mTabletDevice = Utils.useTabletUI(res);
    mListCollapsible = !res.getBoolean(R.bool.is_tablet_landscape);
    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.setIncludeFontPadding(false);
    ViewCompat.setLayoutDirection(mSubjectTextView, layoutDir);
    ViewUtils.setTextAlignment(mSubjectTextView, View.TEXT_ALIGNMENT_VIEW_START);

    mSnippetTextView = new TextView(mContext);
    mSnippetTextView.setEllipsize(TextUtils.TruncateAt.END);
    mSnippetTextView.setIncludeFontPadding(false);
    mSnippetTextView.setTypeface(SANS_SERIF_LIGHT);
    mSnippetTextView.setTextColor(getResources().getColor(R.color.snippet_text_color));
    ViewCompat.setLayoutDirection(mSnippetTextView, layoutDir);
    ViewUtils.setTextAlignment(mSnippetTextView, View.TEXT_ALIGNMENT_VIEW_START);

    // hack for b/16345519. Root cause is b/17280038.
    if (layoutDir == LAYOUT_DIRECTION_RTL) {
        mSubjectTextView.setMaxLines(1);
        mSnippetTextView.setMaxLines(1);
    } else {
        mSubjectTextView.setSingleLine();
        mSnippetTextView.setSingleLine();
    }

    mSendersImageView = new CheckableContactFlipDrawable(res, sCabAnimationDuration);
    mSendersImageView.setCallback(this);

    Utils.traceEndSection();
}

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;/*ww  w . j  a  va2 s  .co  m*/
    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 ava2 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   w  ww  .j  a va 2s .c o  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:com.android.contacts.common.list.ContactListItemView.java

/**
 * Returns the text view for the contact name, creating it if necessary.
 */// w ww  .  j av  a2s  . com
public TextView getNameTextView() {
    if (mNameTextView == null) {
        mNameTextView = new TextView(getContext());
        mNameTextView.setSingleLine(true);
        mNameTextView.setEllipsize(getTextEllipsis());
        mNameTextView.setTextColor(mNameTextViewTextColor);
        mNameTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNameTextViewTextSize);
        // Manually call setActivated() since this view may be added after the first
        // setActivated() call toward this whole item view.
        mNameTextView.setActivated(isActivated());
        mNameTextView.setGravity(Gravity.CENTER_VERTICAL);
        mNameTextView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
        mNameTextView.setId(R.id.cliv_name_textview);
        if (CompatUtils.isLollipopCompatible()) {
            mNameTextView.setElegantTextHeight(false);
        }
        addView(mNameTextView);
    }
    return mNameTextView;
}

From source file:com.android.contacts.common.list.ContactListItemView.java

/**
 * Returns the text view for the phonetic name, creating it if necessary.
 *///from   w ww  .j  av a 2s.c o m
public TextView getPhoneticNameTextView() {
    if (mPhoneticNameTextView == null) {
        mPhoneticNameTextView = new TextView(getContext());
        mPhoneticNameTextView.setSingleLine(true);
        mPhoneticNameTextView.setEllipsize(getTextEllipsis());
        mPhoneticNameTextView.setTextAppearance(getContext(), android.R.style.TextAppearance_Small);
        mPhoneticNameTextView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
        mPhoneticNameTextView.setTypeface(mPhoneticNameTextView.getTypeface(), Typeface.BOLD);
        mPhoneticNameTextView.setActivated(isActivated());
        mPhoneticNameTextView.setId(R.id.cliv_phoneticname_textview);
        addView(mPhoneticNameTextView);
    }
    return mPhoneticNameTextView;
}

From source file:com.android.contacts.list.ContactListItemView.java

/**
 * Returns the text view for the contact name, creating it if necessary.
 *//*from w w  w  .  ja  v a 2  s. c o  m*/
public TextView getNameTextView() {
    if (mNameTextView == null) {
        mNameTextView = new TextView(getContext());
        mNameTextView.setSingleLine(true);
        mNameTextView.setEllipsize(getTextEllipsis());
        mNameTextView.setTextColor(ResourcesCompat.getColorStateList(getResources(),
                R.color.contact_list_name_text_color, getContext().getTheme()));
        mNameTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNameTextViewTextSize);
        // Manually call setActivated() since this view may be added after the first
        // setActivated() call toward this whole item view.
        mNameTextView.setActivated(isActivated());
        mNameTextView.setGravity(Gravity.CENTER_VERTICAL);
        mNameTextView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
        mNameTextView.setId(R.id.cliv_name_textview);
        if (CompatUtils.isLollipopCompatible()) {
            mNameTextView.setElegantTextHeight(false);
        }
        addView(mNameTextView);
    }
    return mNameTextView;
}

From source file:com.android.contacts.common.list.ContactListItemView.java

/**
 * Sets phone number for a list item. This takes care of number highlighting if the highlight
 * mask exists./*from  w  ww . ja va2s.c o  m*/
 */
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);
    }
}

From source file:com.android.contacts.common.list.ContactListItemView.java

/**
 * Returns the text view for the data text, creating it if necessary.
 *//* w  ww.j  a v  a  2  s  .  c  o  m*/
public TextView getDataView() {
    if (mDataView == null) {
        mDataView = new TextView(getContext());
        mDataView.setSingleLine(true);
        mDataView.setEllipsize(getTextEllipsis());
        mDataView.setTextAppearance(getContext(), R.style.TextAppearanceSmall);
        mDataView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
        mDataView.setActivated(isActivated());
        mDataView.setId(R.id.cliv_data_view);
        if (CompatUtils.isLollipopCompatible()) {
            mDataView.setElegantTextHeight(false);
        }
        addView(mDataView);
    }
    return mDataView;
}