private TextView CreateDefaultTabView(Android.Content.Context context) { TextView textView = new TextView(context); textView.LayoutParameters = new LinearLayout.LayoutParams (0, ViewGroup.LayoutParams.WrapContent, 1f); textView.Gravity = GravityFlags.Center; textView.SetTextSize(ComplexUnitType.Sp, TAB_VIEW_TEXT_SIZE_SP); textView.Typeface = Android.Graphics.Typeface.DefaultBold; if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Honeycomb) { TypedValue outValue = new TypedValue(); Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackground, outValue, false); textView.SetBackgroundResource(outValue.ResourceId); } if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.IceCreamSandwich) { textView.SetAllCaps(true); } int padding = (int)(TAB_VIEW_PADDING_DIPS * Resources.DisplayMetrics.Density); textView.SetPadding(padding, padding, padding, padding); return textView; }
TextView MakeHeaderView () { var result = new TextView (context) { Gravity = GravityFlags.Center, TextSize = 10, }; result.SetPadding (4, 4, 4, 4); result.SetBackgroundColor (Color.Rgb (0x22, 0x22, 0x22)); result.SetAllCaps (true); result.SetTypeface (Typeface.DefaultBold, TypefaceStyle.Bold); result.SetTextColor (Color.White); return result; }
private TextView CreateDefaultTabView(Context context) { var textView = new TextView(context); textView.Gravity = GravityFlags.Center; textView.SetTextSize(ComplexUnitType.Sp, TabViewTextSizeSp); textView.Typeface = Typeface.DefaultBold; if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { var outValue = new TypedValue(); Context.Theme.ResolveAttribute(Resource.Attribute.SelectableItemBackground, outValue, false); textView.SetBackgroundResource(outValue.ResourceId); } if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich) { textView.SetAllCaps(true); } var padding = (int) (TabViewPaddingDips*Resources.DisplayMetrics.Density); textView.SetPadding(padding, padding, padding, padding); return textView; }
/** * 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)}. */ protected TextView CreateDefaultTabView(Context context) { TextView textView = new TextView(context); textView.Gravity = Android.Views.GravityFlags.Center; textView.SetTextSize(ComplexUnitType.Sp, 12); textView.Typeface = Typeface.DefaultBold; if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.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(); Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackground,outValue, true); textView.SetBackgroundResource(outValue.ResourceId); } if ((int)Build.VERSION.SdkInt >= 14 || (int)Build.VERSION.SdkInt <= 15){ // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.SetAllCaps(true); } int padding = (int) (16 * Resources.DisplayMetrics.Density); textView.SetPadding(padding, padding, padding, padding); return textView; }
protected TextView CreateDefaultTabView(Context context) { TextView textView = new TextView(context); textView.Gravity = GravityFlags.Center; textView.SetTextSize(ComplexUnitType.Sp, TAB_VIEW_TEXT_SIZE_SP); textView.Typeface = Typeface.DefaultBold; if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Honeycomb) { TypedValue outValue = new TypedValue(); Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackground, outValue, true); textView.SetBackgroundResource(outValue.ResourceId); } if (Build.VERSION.SdkInt >= Build.VERSION_CODES.IceCreamSandwich) { textView.SetAllCaps(true); } int padding = (int)(TAB_VIEW_PADDING_DIPS * Resources.DisplayMetrics.Density); textView.SetPadding(padding, padding, padding, padding); return textView; }