本文整理匯總了Java中android.widget.TextView.setEms方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setEms方法的具體用法?Java TextView.setEms怎麽用?Java TextView.setEms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setEms方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import android.widget.TextView; //導入方法依賴的package包/類
private void init(Context context) {
if (isInEditMode()) return;
mIndicatorView = new AVLoadingIndicatorView(context);
mIndicatorView.setIndicatorId(AVLoadingIndicatorView.Pacman);
mIndicatorView.setIndicatorColor(Color.WHITE);
mIndicatorView.setId(R.id.left);
RelativeLayout.LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(CENTER_IN_PARENT);
addView(mIndicatorView, layoutParams);
mText = new TextView(context);
mText.setEms(6);
mText.setGravity(Gravity.CENTER);
RelativeLayout.LayoutParams textLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
textLayoutParams.addRule(CENTER_IN_PARENT);
textLayoutParams.addRule(BELOW, mIndicatorView.getId());
addView(mText, textLayoutParams);
}
示例2: initView
import android.widget.TextView; //導入方法依賴的package包/類
/**
* Init view.
*
* @param attrs
*/
private void initView(AttributeSet attrs)
{
mRootView = (XPreferenceGreen) LayoutInflater.from(mContext).inflate(R.layout.x_preference, this);
mContainer = (RelativeLayout) mRootView.findViewById(R.id.container);
mTitle = (TextView) mRootView.findViewById(R.id.title);
mContent = (TextView) mRootView.findViewById(R.id.content);
mIndicator = (TextView) mRootView.findViewById(R.id.indicator);
mHintIcons = (LinearLayout) mRootView.findViewById(R.id.hint_icons);
mRightText = (TextView) mRootView.findViewById(R.id.right_text);
TypedArray typedArray = mContext.obtainStyledAttributes(attrs, R.styleable.x_preference);
// Dont need more icon default.
CharSequence label = typedArray.getText(R.styleable.x_preference_label);
int label_ems = typedArray.getInteger(R.styleable.x_preference_label_ems, 0);
if (label_ems > 0)
{
// 設置TextView的寬度為N個字符的寬度
mTitle.setEms(label_ems);
}
Drawable icon = typedArray.getDrawable(R.styleable.x_preference_wo2b_icon);
// Drawable indicator = typedArray.getDrawable(R.styleable.x_preference_indicator);
// <enum name="arrow" value="0" /> as default.
mState = typedArray.getInt(R.styleable.x_preference_indicator_state, STATE_ARROW);
// <enum name="one" value="5" /> as default.
final int position = typedArray.getInt(R.styleable.x_preference_position, 5);
// show notice or not?
mEnabled = typedArray.getBoolean(R.styleable.x_preference_enabled, true);
setTitle(label);
setIcon(icon);
setItemIndicator(mState);
setItemBackground(mContainer, position);
typedArray.recycle();
mContainer.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if (mEnabled)
{
onPreferenceClick(mRootView, mState);
}
else
{
//Toast.makeText(mContext, R.string.hint_not_cancle_power, Toast.LENGTH_SHORT).show();
}
}
});
}