List of usage examples for android.widget TextView setGravity
public void setGravity(int gravity)
From source file:com.altitudelabs.swiftcart.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w w w . ja va 2 s . co m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextSize(getResources().getDimension(R.dimen.pager_tab_strip_slider_textsize)); tab.setTextColor(getResources().getColor(R.color.pager_tab_strip_text_color)); addTab(position, tab); }
From source file:com.jnwat.swmobilegy.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w .j a va2 s . com tab.setGravity(Gravity.CENTER); tab.setSingleLine(); // tab.setTextColor(R.drawable.selector_tabtext); addTab(position, tab); }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout InActivateColorize(LinearLayout ll, String text, Drawable dr) { // text//ww w . j a va 2 s. c om TextView v = (TextView) ll.findViewWithTag("tv"); v.setText(text); v.setTextSize(10); v.setTextColor(Color.GRAY); v.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); dr.setColorFilter(0xFF888888, android.graphics.PorterDuff.Mode.SRC_ATOP); v.setCompoundDrawablesWithIntrinsicBounds(null, dr, null, null); v.setPadding(0, 5, 0, 2); v.setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_tabs)); // hbar View hbar = ll.findViewWithTag("hbar"); hbar.setBackgroundDrawable(null); hbar.setBackgroundColor(resources.getColor(R.color.graylight)); return ll; }
From source file:com.dtd.thevyshka.Utils.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w ww . java 2s.c om */ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mTabCount); textView.setGravity(Gravity.CENTER); textView.setTextSize(12);//TODO adapting to all textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(ContextCompat.getColor(context, R.color.white)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding / 2, padding, padding / 2, padding); return textView; }
From source file:com.abcs.huaqiaobang.tljr.news.tabs.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w w w . j a va2 s . com*/ tab.setGravity(Gravity.CENTER); // DisplayMetrics dm = getResources().getDisplayMetrics(); // tab.setWidth(dm.widthPixels*2/3); tab.setSingleLine(); addTab(position, tab); }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private TextView title() { TextView title = new TextView(context); title.setSingleLine();//from w ww . j a v a2s.c om title.setEllipsize(TruncateAt.END); title.setMaxWidth(UZCoreUtil.dipToPix(maxWidth) - 2 * iconMarginLeft + iconSize); title.setText(getTitle()); title.setTextColor(getTitleColor()); title.setTextSize(getTitleSize()); title.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); return title; }
From source file:com.marlonjones.voidlauncher.allapps.AllAppsGridAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { switch (holder.getItemViewType()) { case VIEW_TYPE_ICON: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); icon.setAccessibilityDelegate(mLauncher.getAccessibilityDelegate()); break;/* www. j a v a2 s . c om*/ } case VIEW_TYPE_PREDICTION_ICON: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); icon.setAccessibilityDelegate(mLauncher.getAccessibilityDelegate()); break; } case VIEW_TYPE_EMPTY_SEARCH: TextView emptyViewText = (TextView) holder.mContent; emptyViewText.setText(mEmptySearchMessage); emptyViewText.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); break; case VIEW_TYPE_SEARCH_MARKET: TextView searchView = (TextView) holder.mContent; if (mMarketSearchIntent != null) { searchView.setVisibility(View.VISIBLE); } else { searchView.setVisibility(View.GONE); } break; } if (mBindViewCallback != null) { mBindViewCallback.onBindView(holder); } }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private TextView subTitle() { TextView title = new TextView(context); title.setSingleLine();/*from w w w . ja v a2 s . co m*/ title.setEllipsize(TruncateAt.END); title.setMaxWidth(UZCoreUtil.dipToPix(maxWidth) - 2 * iconMarginLeft + iconSize); title.setText(getSubTitle()); title.setTextColor(getSubTitleColor()); title.setTextSize(getSubTitleSize()); title.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); return title; }
From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);// w w w.j a va2 s.co m tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { switch (holder.getItemViewType()) { case ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); break;// w ww .j av a2 s . c o m } case PREDICTION_ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); break; } case EMPTY_SEARCH_VIEW_TYPE: TextView emptyViewText = (TextView) holder.mContent; emptyViewText.setText(mEmptySearchMessage); emptyViewText.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); break; case SEARCH_MARKET_VIEW_TYPE: TextView searchView = (TextView) holder.mContent; if (mMarketSearchIntent != null) { searchView.setVisibility(View.VISIBLE); searchView.setContentDescription(mMarketSearchMessage); searchView.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); searchView.setText(mMarketSearchMessage); } else { searchView.setVisibility(View.GONE); } break; } }