List of usage examples for android.widget TextView setTextSize
public void setTextSize(int unit, float size)
From source file:com.ashoksm.pinfinder.common.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 ava2s . c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.parseColor("#99ffffff")); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); 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, padding, padding, padding); return textView; }
From source file:com.example.alex.helloworld.SlidingTabLayout.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 w w . j a v a 2s. c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setTextColor(getResources().getColor(R.color.weiss)); 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); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.dianxun.holyn.lucky.view.widget.ViewpagerHeaderScroll.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set * via/*from w w w. j a v a2 s . co m*/ * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextColor(getResources().getColor(R.color.black)); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); // textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(0, padding, 0, padding); return textView; }
From source file:br.edu.ifpb.breath.slidingtabs.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, int)}. */// ww w . ja va 2 s. c o m protected View createDefaultTabView(Context context, int type) { if (type == 0) { 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); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; } else { ImageView iconView = new ImageView(context); int iconSize = (int) (TAB_VIEW_ICON_SIZE_DIPS * getResources().getDisplayMetrics().density); int padding = (int) (TAB_VIEW_ICON_PADDING_DIPS * getResources().getDisplayMetrics().density); iconView.setLayoutParams(new LinearLayout.LayoutParams(iconSize + padding, iconSize + padding)); iconView.setScaleType(ImageView.ScaleType.FIT_CENTER); iconView.setPadding(padding, padding, padding, padding); return iconView; } }
From source file:com.android.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)}./*from www .j a va2s . c om*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setSingleLine(); textView.setEllipsize(TextUtils.TruncateAt.END); 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)); textView.setTextColor(Color.WHITE); int hpadding = (int) (TAB_VIEW_HORIZONTAL_PADDING_DIPS * getResources().getDisplayMetrics().density); int vpadding = (int) (TAB_VIEW_VERTICAL_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(hpadding, vpadding, hpadding, vpadding); return textView; }
From source file:at.wada811.android.dialogfragments.sample.alertdialogfragment.AlertDialogFragmentExamplesFragment.java
@Override public DialogFragmentCallback getDialogFragmentCallback() { return new SimpleDialogFragmentCallback() { @Override/* w w w.j a v a2 s . c o m*/ public void onShow(DialogFragmentInterface dialog) { String text = "onShow"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onCancel(DialogFragmentInterface dialog) { String text = "onCancel"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onDismiss(DialogFragmentInterface dialog) { String text = "onDismiss"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onClickPositive(DialogFragmentInterface dialog) { String text = "onClickPositive"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onClickNeutral(DialogFragmentInterface dialog) { String text = "onClickNeutral"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onClickNegative(DialogFragmentInterface dialog) { String text = "onClickNegative"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public boolean onKey(DialogFragmentInterface dialog, int keyCode, KeyEvent event) { String text = "onKey[keyCode: " + keyCode + ", KeyEvent: " + event + "]"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); return false; } @Override public void onItemClick(DialogFragmentInterface dialog, int position) { Bundle extra = dialog.getExtra(); String[] items = extra.getStringArray("items"); String text = "onItemClick[position: " + position + ", item: " + items[position] + "]"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public ListAdapter getAdapter(DialogFragmentInterface dialog) { String[] items = new String[] { AlertDialog.class.getSimpleName(), CharacterPickerDialog.class.getSimpleName(), ProgressDialog.class.getSimpleName(), DatePickerDialog.class.getSimpleName(), TimePickerDialog.class.getSimpleName(), }; Bundle extra = new Bundle(); extra.putStringArray("items", items); dialog.setExtra(extra); return new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, items); } @Override public void onSingleChoiceClick(DialogFragmentInterface dialog, int position) { Bundle extra = dialog.getExtra(); String[] items = extra.getStringArray("items"); String text = "onItemClick[position: " + position + ", item: " + items[position] + "]"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onMultiChoiceClick(DialogFragmentInterface dialog, int position, boolean isChecked) { Bundle extra = dialog.getExtra(); String[] items = extra.getStringArray("items"); String text = "onItemClick[position: " + position + ", item: " + items[position] + ", isChecked: " + isChecked + "]"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public View getCustomTitle(DialogFragmentInterface dialog) { TextView titleView = new TextView(getActivity()); titleView.setText(dialog.getTag()); titleView.setPadding(0, 24, 0, 24); titleView.setGravity(Gravity.CENTER); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); return titleView; } @Override public View getView(DialogFragmentInterface dialog) { ImageView imageView = new ImageView(getActivity()); imageView.setImageResource(R.drawable.ic_launcher); imageView.setPadding(0, 24, 0, 24); return imageView; } }; }
From source file:cn.caimatou.canting.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)}.//from www . ja v a 2 s .c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); int textSize = (mTextSize <= 0 ? TAB_VIEW_TEXT_SIZE_SP : mTextSize); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); 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); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.cookbeans.boredapp.ui.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 ww w . j ava 2 s. co m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.WHITE); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); // textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTypeface(Typeface.DEFAULT); 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, padding, padding, padding); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f); textView.setLayoutParams(layoutParams); return textView; }
From source file:com.example.chicharo.clean_ambar.util.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 av a 2s. c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); // textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); 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, //Ripple effect 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.androprogrammer.tutorials.customviews.SlidingTabLayout.java
protected TextView createDefaultTextTabView(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); 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 w w w . j av a 2 s . c o 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); //System.out.println("c " + titleColor); if (titleColor != null) { textView.setTextColor(titleColor); } return textView; }