Customizing ActionBar Tabs on Android 4

后端 未结 7 1664
甜味超标
甜味超标 2021-01-01 19:26

I\'m trying to customize Tabs on my ActionBar. I just want to align tabs to phone screen and make it stretchable for various screens. But all I get is this:

7条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 20:04

    I have found using style guides for the tabs to very inconsistent for honeycomb, It was much easier to just inflate a custom view that does want you want.

    Fragment serivceFrag = new ServicesFragment();
    Tab serviceTab = bar.newTab();
    TextViewPlus serviceTabTextView =(TextViewPlus)getLayoutInflater().inflate(R.layout.tab_item_layout, null);
    serviceTabTextView.setText(servicesLabel);
    serviceTab.setCustomView(serviceTabTextView);
    serviceTab.setTabListener(new TabListenerFragment(serivceFrag,"Service",R.id.MainInfoPaneFragment));
    bar.addTab(serviceTab);
    

    This to me was much simpler,

提交回复
热议问题