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

The following are Jave code examples for showing how to use getParent() 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: decoy   File: MsgHolder.java   View Source Code Vote up 6 votes
@Override
public View inflate(LayoutInflater inflater) {
    View view = inflater.inflate(R.layout.nim_contacts_item, null);

    head = (HeadImageView) view.findViewById(R.id.contacts_item_head);
    name = (TextView) view.findViewById(R.id.contacts_item_name);
    time = (TextView) view.findViewById(R.id.contacts_item_time);
    desc = (TextView) view.findViewById(R.id.contacts_item_desc);

    // calculate
    View parent = (View) desc.getParent();
    if (parent.getMeasuredWidth() == 0) {
        // xml中:50dp,包括头像的长度还有左右间距大小
        parent.measure(View.MeasureSpec.makeMeasureSpec(ScreenUtil.getDisplayWidth() - ScreenUtil.dip2px(50.0f), View.MeasureSpec.EXACTLY), 0);
    }
    descTextViewWidth = (int) (parent.getMeasuredWidth() - desc.getPaint().measureText(PREFIX));

    return view;
}
 
Example 2
Project: GitHub   File: CalligraphyFactory.java   View Source Code Vote up 5 votes
/**
 * An even dirtier way to see if the TextView is part of the ActionBar
 *
 * @param view TextView to check is Title
 * @return true if it is.
 */
@SuppressLint("NewApi")
protected static boolean isActionBarTitle(TextView view) {
    if (matchesResourceIdName(view, ACTION_BAR_TITLE)) return true;
    if (parentIsToolbarV7(view)) {
        final android.support.v7.widget.Toolbar parent = (android.support.v7.widget.Toolbar) view.getParent();
        return TextUtils.equals(parent.getTitle(), view.getText());
    }
    return false;
}
 
Example 3
Project: GitHub   File: CalligraphyFactory.java   View Source Code Vote up 5 votes
/**
 * An even dirtier way to see if the TextView is part of the ActionBar
 *
 * @param view TextView to check is Title
 * @return true if it is.
 */
@SuppressLint("NewApi")
protected static boolean isActionBarSubTitle(TextView view) {
    if (matchesResourceIdName(view, ACTION_BAR_SUBTITLE)) return true;
    if (parentIsToolbarV7(view)) {
        final android.support.v7.widget.Toolbar parent = (android.support.v7.widget.Toolbar) view.getParent();
        return TextUtils.equals(parent.getSubtitle(), view.getText());
    }
    return false;
}
 
Example 4
Project: DownloadableCalligraphy   File: CalligraphyFactory.java   View Source Code Vote up 5 votes
/**
 * An even dirtier way to see if the TextView is part of the ActionBar
 *
 * @param view TextView to check is Title
 * @return true if it is.
 */
@SuppressLint("NewApi")
protected static boolean isActionBarTitle(TextView view) {
    if (matchesResourceIdName(view, ACTION_BAR_TITLE)) return true;
    if (parentIsToolbarV7(view)) {
        final android.support.v7.widget.Toolbar parent = (android.support.v7.widget.Toolbar) view.getParent();
        return TextUtils.equals(parent.getTitle(), view.getText());
    }
    return false;
}
 
Example 5
Project: DownloadableCalligraphy   File: CalligraphyFactory.java   View Source Code Vote up 5 votes
/**
 * An even dirtier way to see if the TextView is part of the ActionBar
 *
 * @param view TextView to check is Title
 * @return true if it is.
 */
@SuppressLint("NewApi")
protected static boolean isActionBarSubTitle(TextView view) {
    if (matchesResourceIdName(view, ACTION_BAR_SUBTITLE)) return true;
    if (parentIsToolbarV7(view)) {
        final android.support.v7.widget.Toolbar parent = (android.support.v7.widget.Toolbar) view.getParent();
        return TextUtils.equals(parent.getSubtitle(), view.getText());
    }
    return false;
}