我目前有一个使用选项卡式导航实现的actionBar,现在想要自定义选项卡.我为每个选项卡创建了一个自定义XML布局,以获得textview和可单击的ImageButton,并使用ActionBar.Tab.setCustomView进行设置.问题是布局的所有属性都没有任何效果(例如对齐).任何帮助,将不胜感激!
这是一张显示产生的图像:正在制作的图像
我的自定义选项卡布局XML文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/tab_title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_action_refresh"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
ActionBar代码:
final ActionBar actionBar = getActionBar();
//Because there is no 'parent' when navigating from the action bar, the home button for the Action Bar is disabled.
actionBar.setHomeButtonEnabled(false);
//Specify that the actionBar will include a tabbed navigation
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Setting up the ViewPager rowingViewPager, attaching the RowingFragmentPagerAdapter and setting up a listener for when …Run Code Online (Sandbox Code Playgroud)