Android TabWidget in Light theme

前端 未结 4 1808
生来不讨喜
生来不讨喜 2021-02-09 17:00

I have an application that targets the 1.5 framework and uses the default light theme. When using a tab widget with this theme, the tab images are barely visible, and the tab ca

4条回答
  •  时光取名叫无心
    2021-02-09 17:08

    it's not pretty, but you can try this in your tab activity.

    // light theme support
    final TabHost tabHost = getTabHost();
    tabHost.setBackgroundColor(Color.WHITE);
    tabHost.getTabWidget().setBackgroundColor(Color.BLACK);
    
    // hack to set font size
    LinearLayout ll = (LinearLayout) tabHost.getChildAt(0);
    TabWidget tw = (TabWidget) ll.getChildAt(0);
    
    // first tab
    RelativeLayout rllf = (RelativeLayout) tw.getChildAt(0);
    lf = (TextView) rllf.getChildAt(1);
    lf.setTextSize(21);
    lf.setPadding(0, 0, 0, 6);
    
    // second tab
    RelativeLayout rlrf = (RelativeLayout) tw.getChildAt(1);
    rf = (TextView) rlrf.getChildAt(1);
    rf.setTextSize(21);
    rf.setPadding(0, 0, 0, 6);
    

    /res/values/colors.xml should have

    
        #ff000000
        #ffffffff
    
    

    AndroidManiest.xml should have

    
    

    if you want to do something crazier, try http://ezmobile.wordpress.com/2009/02/02/customized-android-tabs/

提交回复
热议问题