Android 带有图像的自定义选项卡栏
我正在尝试创建一个如下图所示的选项卡栏(即左侧有一些图像的选项卡栏) 白色部分是两个图像,而黑色部分是选项卡标签Android 带有图像的自定义选项卡栏,android,tabs,Android,Tabs,我正在尝试创建一个如下图所示的选项卡栏(即左侧有一些图像的选项卡栏) 白色部分是两个图像,而黑色部分是选项卡标签 有人能指导我做同样的事吗 使用actionBar.addTab(actionBar.newTab() //.setText(mSectionsPagerAdapter.getPageTitle(i)) .setCustomView(视图) .setTabListener(本)) 在这里,您可以自定义布局并将其解析到视图中 请参见[我在没有使用操作栏的情况下找到了一个解决方法。只需对
有人能指导我做同样的事吗 使用
actionBar.addTab(actionBar.newTab()
//.setText(mSectionsPagerAdapter.getPageTitle(i))
.setCustomView(视图)
.setTabListener(本))代码>
在这里,您可以自定义布局并将其解析到视图中
请参见[我在没有使用操作栏的情况下找到了一个解决方法。只需对XML代码进行一些调整,我就可以开始了。我做了以下几点:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<RelativeLayout
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/tab_bg" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/options"
android:layout_gravity="center"
android:layout_marginLeft="10dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignLeft="@+id/linear"
android:layout_below="@+id/linear">
</FrameLayout>
</RelativeLayout>
</TabHost>
制作这样的选项卡栏需要使用操作栏?没有其他方法吗?如果问题是noobish,很抱歉,但我是android新手。选项卡栏?嗯,您可以使用tab host:)当然,您只需在顶部添加布局并自定义即可。