我正在尝试在操作栏中创建一个自定义选项卡视图,如下所示:
我得到了这样的看法:
我想更改标签视图指示器的背景,因此背景颜色变得不可见,并且我们在选定的标签视图指示器下方有绿线。
这是我的代码(我使用默认的tabview):
public class BaseActivity extends Activity{
ActionBar bar;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); setContentView(R.layout.base_activity);
bar = getActionBar();
// Change action bar background
BitmapDrawable background = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.background_actionbar)); background.setTileModeX(android.graphics.Shader.TileMode.REPEAT);
bar.setBackgroundDrawable(background);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tabA = bar.newTab().setText(getResources().getString(R.string.documents));
ActionBar.Tab tabB = bar.newTab().setText(getResources().getString(R.string.videos));
ActionBar.Tab tabC = bar.newTab().setText(getResources().getString(R.string.menu_settings));
Fragment fragmentA = new DocumentsListFragment();
Fragment fragmentB = new VideosListFragment();
Fragment fragmentC = new UserAccountFragment();
tabA.setTabListener(new MyTabsListener(fragmentA));
tabB.setTabListener(new MyTabsListener(fragmentB));
tabC.setTabListener(new MyTabsListener(fragmentC));
bar.addTab(tabA);
bar.addTab(tabB);
bar.addTab(tabC);
}
protected class MyTabsListener implements ActionBar.TabListener
{
private Fragment fragment;
public MyTabsListener(Fragment fragment) {
this.fragment = fragment; }
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft)
{
ft.replace(R.id.fragment_place, fragment, null); }
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
}
}
拜托,我怎样才能夸大那些标签视图指示器。