Java Code Examples for android.support.v7.widget.AppCompatTextView#setGravity()
The following examples show how to use
android.support.v7.widget.AppCompatTextView#setGravity() .
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: DotLayout.java From nono-android with GNU General Public License v3.0 | 6 votes |
@Override protected void initUI() { LinearLayout linearLayout=new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); textView=new AppCompatTextView(getContext()); int size=(int)(getResources().getDisplayMetrics().density*32); LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(size,size); //lp.gravity=Gravity.CENTER_VERTICAL; textView.setLayoutParams(lp); textView.setText("ยท"); textView.setTextColor(0xff000000); textView.setTextAppearance(getContext(),R.style.DotTextAppearance); textView.setGravity(Gravity.CENTER); editText=new BaseRichEditText(getContext()); editText.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,1.0f)); linearLayout.addView(textView); linearLayout.addView(editText); this.addView(linearLayout); }
Example 2
Source File: NumericLayout.java From nono-android with GNU General Public License v3.0 | 6 votes |
@Override protected void initUI() { LinearLayout linearLayout=new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); textView=new AppCompatTextView(getContext()); int size=(int)(getResources().getDisplayMetrics().density*32); LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(size,size); //lp.gravity= Gravity.CENTER_VERTICAL; textView.setLayoutParams(lp); textView.setTextColor(0xff000000); textView.setGravity(Gravity.CENTER); editText=new BaseRichEditText(getContext()); editText.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,1.0f)); linearLayout.addView(textView); linearLayout.addView(editText); this.addView(linearLayout); }
Example 3
Source File: IndexableLayout.java From IndexableRecyclerView with Apache License 2.0 | 6 votes |
private void initMDOverlay(int color) { mMDOverlay = new AppCompatTextView(mContext); mMDOverlay.setBackgroundResource(R.drawable.indexable_bg_md_overlay); ((AppCompatTextView) mMDOverlay).setSupportBackgroundTintList(ColorStateList.valueOf(color)); mMDOverlay.setSingleLine(); mMDOverlay.setTextColor(Color.WHITE); mMDOverlay.setTextSize(38); mMDOverlay.setGravity(Gravity.CENTER); int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 72, getResources().getDisplayMetrics()); LayoutParams params = new LayoutParams(size, size); params.rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 33, getResources().getDisplayMetrics()); params.gravity = Gravity.END; mMDOverlay.setLayoutParams(params); mMDOverlay.setVisibility(INVISIBLE); addView(mMDOverlay); }
Example 4
Source File: IndexableStickyListView.java From SprintNBA with Apache License 2.0 | 5 votes |
private void initRightOverlayTextView(int color) { mTvRightOverlay = new AppCompatTextView(mContext); mTvRightOverlay.setBackgroundResource(R.drawable.bg_right_overlay); mTvRightOverlay.setSupportBackgroundTintList(ColorStateList.valueOf(color)); mTvRightOverlay.setTextColor(Color.WHITE); mTvRightOverlay.setTextSize(38); mTvRightOverlay.setGravity(Gravity.CENTER); int size = IndexBar.dp2px(mContext, 72); LayoutParams params = new LayoutParams(size, size); params.rightMargin = IndexBar.dp2px(mContext, 33); params.gravity = Gravity.RIGHT; mTvRightOverlay.setLayoutParams(params); mTvRightOverlay.setVisibility(INVISIBLE); }
Example 5
Source File: CircularTabLayoutAdapter.java From CircularViewPager with MIT License | 4 votes |
final void update(CircularTabLayout.Tab tab) { ColorStateList tabTextColors = tab.getTextColorStateList() == null ? mTabTextColors : tab.getTextColorStateList(); mTab = tab; View custom = tab.getCustomView(); if (custom != null) { ViewParent icon = custom.getParent(); if (icon != this) { if (icon != null) { ((ViewGroup) icon).removeView(custom); } addView(custom); } mCustomView = custom; if (mTextView != null) { mTextView.setVisibility(View.GONE); } if (mIconView != null) { mIconView.setVisibility(View.GONE); mIconView.setImageDrawable(null); } } else { if (mCustomView != null) { removeView(mCustomView); mCustomView = null; } Drawable icon1 = tab.getIcon(); CharSequence text = tab.getText(); if (icon1 != null) { if (mIconView == null) { ImageView hasText = new ImageView(getContext()); LayoutParams textView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); textView.gravity = Gravity.CENTER_VERTICAL; hasText.setLayoutParams(textView); addView(hasText, 0); mIconView = hasText; } mIconView.setImageDrawable(icon1); mIconView.setVisibility(View.VISIBLE); } else if (mIconView != null) { mIconView.setVisibility(View.GONE); mIconView.setImageDrawable(null); } boolean hasText1 = !TextUtils.isEmpty(text); if (hasText1) { if (mTextView == null) { AppCompatTextView textView1 = new AppCompatTextView(getContext()); textView1.setTextAppearance(getContext(), mTabTextAppearance); if (mTabTextSize != -1) { textView1.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize); } textView1.setMaxLines(MAX_TAB_TEXT_LINES); textView1.setEllipsize(TextUtils.TruncateAt.END); textView1.setGravity(Gravity.CENTER); if (tabTextColors != null) { textView1.setTextColor(tabTextColors); } addView(textView1, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mTextView = textView1; } mTextView.setText(text); mTextView.setContentDescription(tab.getContentDescription()); mTextView.setVisibility(View.VISIBLE); } else if (mTextView != null) { mTextView.setVisibility(View.GONE); mTextView.setText(null); } if (mIconView != null) { mIconView.setContentDescription(tab.getContentDescription()); } if (!hasText1 && !TextUtils.isEmpty(tab.getContentDescription())) { setOnLongClickListener(this); setLongClickable(true); } else { setOnLongClickListener(null); setLongClickable(false); } } }
Example 6
Source File: CircularTabLayoutAdapter.java From CircularViewPager with MIT License | 4 votes |
final void update(CircularTabLayout.Tab tab) { ColorStateList tabTextColors = tab.getTextColorStateList() == null ? mTabTextColors : tab.getTextColorStateList(); mTab = tab; View custom = tab.getCustomView(); if (custom != null) { ViewParent icon = custom.getParent(); if (icon != this) { if (icon != null) { ((ViewGroup) icon).removeView(custom); } addView(custom); } mCustomView = custom; if (mTextView != null) { mTextView.setVisibility(View.GONE); } if (mIconView != null) { mIconView.setVisibility(View.GONE); mIconView.setImageDrawable(null); } } else { if (mCustomView != null) { removeView(mCustomView); mCustomView = null; } Drawable icon1 = tab.getIcon(); CharSequence text = tab.getText(); if (icon1 != null) { if (mIconView == null) { ImageView hasText = new ImageView(getContext()); LayoutParams textView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); textView.gravity = Gravity.CENTER_VERTICAL; hasText.setLayoutParams(textView); addView(hasText, 0); mIconView = hasText; } mIconView.setImageDrawable(icon1); mIconView.setVisibility(View.VISIBLE); } else if (mIconView != null) { mIconView.setVisibility(View.GONE); mIconView.setImageDrawable(null); } boolean hasText1 = !TextUtils.isEmpty(text); if (hasText1) { if (mTextView == null) { AppCompatTextView textView1 = new AppCompatTextView(getContext()); textView1.setTextAppearance(getContext(), mTabTextAppearance); if (mTabTextSize != -1) { textView1.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize); } textView1.setMaxLines(MAX_TAB_TEXT_LINES); textView1.setEllipsize(TextUtils.TruncateAt.END); textView1.setGravity(Gravity.CENTER); if (tabTextColors != null) { textView1.setTextColor(tabTextColors); } addView(textView1, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mTextView = textView1; } mTextView.setText(text); mTextView.setContentDescription(tab.getContentDescription()); mTextView.setVisibility(View.VISIBLE); } else if (mTextView != null) { mTextView.setVisibility(View.GONE); mTextView.setText(null); } if (mIconView != null) { mIconView.setContentDescription(tab.getContentDescription()); } if (!hasText1 && !TextUtils.isEmpty(tab.getContentDescription())) { setOnLongClickListener(this); setLongClickable(true); } else { setOnLongClickListener(null); setLongClickable(false); } } }