ActionBar 选项卡的粗细/宽度

发布于 2025-01-01 07:50:52 字数 76 浏览 6 评论 0原文

我有一个带有 3 个选项卡的操作栏。 它看起来像这样: |全部 |来电 |网络| 我希望它们具有相同的宽度。我该怎么做呢?

I have an action bar with 3 tabs in it.
It looks like this:
| All | Calls | Network |
I want them to have the same width. How can I do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

帅哥哥的热头脑 2025-01-08 07:50:52

您可以使用 ActionBar.Tab 上的 setCustomView() 方法为任何视图设置标签。我就是这样做的。自定义视图是从布局加载的,在我的例子中,该布局类似于 ActionBar.Tag 使用的内置布局,您可以将边距、大小和内容设置为您需要的任何内容。

You can set a tag to any view using setCustomView() method on the ActionBar.Tab. This is how I did it. The custom view is loaded from a layout that in my case was similar to the built-in layout used by ActionBar.Tag, you set the margins, sizes, and content to whatever you need.

扛起拖把扫天下 2025-01-08 07:50:52

它们都以相同的宽度对齐在行中

<?xml version="1.0" encoding="utf-8"?>
<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"  >
<LinearLayout
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
<HorizontalScrollView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:fillViewport="true"
   android:scrollbars="none">
<TabWidget 
   android:id="@android:id/tabs"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"/>
 </HorizontalScrollView>
 <FrameLayout
   android:id="@android:id/tabcontent"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" />
 </LinearLayout>
</TabHost>

然后将选项卡主机设置为

  TabHost tabHost;
TabHost.TabSpec spec;
tabHost=getTabHost()
Intent intent;
 intent=new Intent().setClass(this, BirthDayTab.class);
 spec=tabHost.newTabSpec("artists").setIndicator("BirthDay",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
 tabHost.addTab(spec);

They all align in the row with same width

<?xml version="1.0" encoding="utf-8"?>
<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"  >
<LinearLayout
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
<HorizontalScrollView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:fillViewport="true"
   android:scrollbars="none">
<TabWidget 
   android:id="@android:id/tabs"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"/>
 </HorizontalScrollView>
 <FrameLayout
   android:id="@android:id/tabcontent"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" />
 </LinearLayout>
</TabHost>

And then set tab host as

  TabHost tabHost;
TabHost.TabSpec spec;
tabHost=getTabHost()
Intent intent;
 intent=new Intent().setClass(this, BirthDayTab.class);
 spec=tabHost.newTabSpec("artists").setIndicator("BirthDay",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
 tabHost.addTab(spec);
聚集的泪 2025-01-08 07:50:52

https://groups.google.com/forum/#!topic/actionbarsherlock/4oT9KwhB0O8
这就是我几天来一直在寻找的确切解决方案

https://groups.google.com/forum/#!topic/actionbarsherlock/4oT9KwhB0O8
This is the exact solution that I have been looking for days

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文