Sliding tab layout text is uppercase

前端 未结 3 1305
无人及你
无人及你 2021-01-12 13:12

Hi I\'m using Sliding tab layout in my app and it all works great. The only thing I dont understand is why my tabs text are in uppercase.

I\'ve printed the text the

3条回答
  •  春和景丽
    2021-01-12 13:20

    Found the answer it was in the createDefaultTabView() method.

    Needed to change textView.setAllCaps(true) to false.

    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.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); **// Changed to false and it did the trick**
    
        int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
        textView.setPadding(padding, padding, padding, padding);
    
        return textView;
    }
    

提交回复
热议问题