本文整理汇总了Java中android.widget.TextView.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.getParent方法的具体用法?Java TextView.getParent怎么用?Java TextView.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.getParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inflate
import android.widget.TextView; //导入方法依赖的package包/类
@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;
}
示例2: isActionBarTitle
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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;
}
示例3: isActionBarSubTitle
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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;
}