Java Code Examples for android.widget.TextView#setEms()
The following examples show how to use
android.widget.TextView#setEms() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OverScrollLayout.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); mOverScrollView = new OverScrollView(getContext()); mOverScrollTextView = new TextView(getContext()); mOverScrollTextView.setEms(1); mOverScrollTextView.setLineSpacing(0, 0.8f); mOverScrollTextView.setText(OVER_SCROLL_TEXT); mOverScrollTextView.setTextSize(11f); mOverScrollTextView.setTextColor(Color.parseColor("#CDCDCD")); addView(mOverScrollView); addView(mOverScrollTextView); }
Example 2
Source File: BindHorizontalCustomLoadMoreFooter.java From LazyRecyclerAdapter with MIT License | 5 votes |
/** * 初始化view */ void initView() { setGravity(Gravity.CENTER); setOrientation(VERTICAL); setLayoutParams(new RecyclerView.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); setPadding(0, (int) getResources().getDimension(R.dimen.textandiconmargin), 0, (int) getResources().getDimension(R.dimen.textandiconmargin)); mImageView = new ImageView(getContext()); mImageView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mImageView.setImageResource(R.drawable.progressbar); addView(mImageView); mText = new TextView(getContext()); mText.setEms(1); mText.setText("正在加载..."); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins((int) getResources().getDimension(R.dimen.textandiconmargin), 0, 0, 0); mText.setLayoutParams(layoutParams); addView(mText); mAnimationDrawable = (AnimationDrawable) mImageView.getDrawable(); }
Example 3
Source File: XPreferenceGreen.java From android-project-wo2b with Apache License 2.0 | 4 votes |
/** * 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_rocky_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(); } } }); }