List of usage examples for android.widget TextView setPadding
@Override public void setPadding(int left, int top, int right, int bottom)
From source file:com.licubeclub.zionhs.view.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 w w . j a v a 2 s . co m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 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, padding, padding, padding); return textView; }
From source file:com.community.yuequ.bottombar.BottomBar.java
private void updateTitleBottomPadding() { if (tabContainer == null) { return;//w w w .jav a 2 s. com } int childCount = getTabCount(); for (int i = 0; i < childCount; i++) { View tab = tabContainer.getChildAt(i); TextView title = (TextView) tab.findViewById(R.id.bb_bottom_bar_title); if (title == null) { continue; } int baseline = title.getBaseline(); int height = title.getHeight(); int paddingInsideTitle = height - baseline; int missingPadding = tenDp - paddingInsideTitle; if (missingPadding > 0) { title.setPadding(title.getPaddingLeft(), title.getPaddingTop(), title.getPaddingRight(), missingPadding + title.getPaddingBottom()); } } }
From source file:com.simplecity.amp_library.ui.views.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)}./* w ww . j a va2s . c om*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setTypeface(TypefaceManager.getInstance().getTypeface(TypefaceManager.SANS_SERIF_MEDIUM)); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setMinWidth(ResourceUtils.toPixels(72)); textView.setSingleLine(true); // 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(R.attr.list_selector, outValue, true); textView.setBackgroundResource(outValue.resourceId); // 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, padding, padding, padding); return textView; }
From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java
/** * Create or recreate the limiter breadcrumbs. *//*from ww w . ja v a 2s .co m*/ public void updateLimiterViews() { mLimiterViews.removeAllViews(); Limiter limiterData = mPagerAdapter.getCurrentLimiter(); if (limiterData != null) { String[] limiter = limiterData.names; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = 5; for (int i = 0; i != limiter.length; ++i) { PaintDrawable background = new PaintDrawable(Color.GRAY); background.setCornerRadius(5); TextView view = new TextView(this); view.setSingleLine(); view.setEllipsize(TextUtils.TruncateAt.MARQUEE); view.setText(limiter[i] + " | X"); view.setTextColor(Color.WHITE); view.setBackgroundDrawable(background); view.setLayoutParams(params); view.setPadding(5, 2, 5, 2); view.setTag(i); view.setOnClickListener(this); mLimiterViews.addView(view); } mLimiterScroller.setVisibility(View.VISIBLE); } else { mLimiterScroller.setVisibility(View.GONE); } }
From source file:com.example.zihua.widget.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)}.// www.j av a 2s . c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); } textView.setBackgroundResource(outValue.resourceId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.ciandt.thegarage.navapp.view.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 w w . ja v a2 s . c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); //TypefaceUtil.loadCustomFonts(context, Constants.Font.MUSEO_REGULAR500, textView); textView.setTextColor(context.getResources().getColor(android.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); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding + 20, padding, padding + 20, padding); return textView; }
From source file:com.mobicage.rogerthat.SendMessageButtonActivity.java
private void setButtonItemView(final View view, CannedButton item) { TextView captionTextView = (TextView) view.findViewById(R.id.caption); TextView actionTextView = (TextView) view.findViewById(R.id.action); captionTextView.setTextColor(ContextCompat.getColor(mService, android.R.color.primary_text_light)); actionTextView.setTextColor(ContextCompat.getColor(mService, android.R.color.secondary_text_light)); ImageView statusImageView = (ImageView) view.findViewById(R.id.status); UIUtils.setBackgroundColor(statusImageView, LookAndFeelConstants.getPrimaryColor(this)); statusImageView.setVisibility(item.isSelected() ? View.VISIBLE : View.GONE); captionTextView.setText(item.getCaption()); String action = item.getAction(); if (action == null) { actionTextView.setVisibility(View.GONE); captionTextView.setPadding(0, 13, 0, 13); } else {/*from www. ja v a 2 s. c o m*/ actionTextView.setVisibility(View.VISIBLE); actionTextView.setText(action); captionTextView.setPadding(0, 0, 0, 0); } view.setTag(item); }
From source file:com.mohamadamin.fastsearch.free.modules.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)}.//ww w .jav a2s. c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); textView.setClickable(true); int paddingSide = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); int paddingTop = (int) (9 * getResources().getDisplayMetrics().density); int paddingBottom = (int) (12 * getResources().getDisplayMetrics().density); textView.setPadding(paddingSide, paddingTop, paddingSide, paddingBottom); return textView; }
From source file:com.axum.darivb.searchview.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(bariol_regular_tf); 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); }//from www.j a v a 2 s .co m 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, padding, padding, padding); return textView; }
From source file:com.dotcom.jamaat.view.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)}.// w ww . j ava 2 s. c o m */ protected TextView createDefaultTabView(Context context) { // TextView textView = new TextView(context); // textView.setGravity(Gravity.CENTER); // textView.setTextSize(context.getResources().getDimension(R.dimen.dimen_9_sp)); // textView.setTypeface(Typeface.DEFAULT); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); Typeface font = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Regular.ttf"); textView.setTypeface(font); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(false); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(10, padding, 10, padding); return textView; /*// WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 3); //*/ // 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(0,20,0,20); // // return textView; }