[英]Custom Tab Bar with images
我正在尝试创建一个标签栏,如下图所示(即,左侧有一些图片的标签栏)。
白色部分是两张图片,黑色部分是标签
有人可以指导我这样做吗?
使用actionBar.addTab(actionBar.newTab() //.setText(mSectionsPagerAdapter.getPageTitle(i)) .setCustomView(view) .setTabListener(this));
在这里,您可以自定义布局并将其解析为视图,请参阅[ 如何在ActionBar的导航选项卡中设置自定义视图,并使这些选项卡适应其高度?
我设法不使用操作栏就找到了解决方法。 只是一些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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.