本文整理匯總了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;
}