是否可以将Android Tabhost设置为类似iPhone的样式?如果没有,是否有任何开源代码可以显示如何为Android创建底部选项卡?
alt text http://images.appshopper.com/screenshots/305/690205_2.jpg
如何更改选项卡的字体大小?我为选项卡扩展了TabActivity.
我已经制作了一个应用程序,其中包含HelloTabActivity中的标签,这些标签之间也有空格,任何人都可以建议如何删除此空间,并且标签下方还有一条灰色线条如何删除?
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost
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"
android:padding="5dp" >
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
android:padding="5dp" />
</LinearLayout>
</TabHost>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomTheme" parent="@android:style/Theme">
<item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
<item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText"
parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">10sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#1589FF</item>
<item name="android:padding">3dip</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
活动
public class InfralineTabWidget extends TabActivity{
public void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud) android tabwidget android-layout android-style-tabhost android-tabhost
我正在尝试用2个标签做一个tabHost,它没关系,但是我想改变文字大小,我搜索了很多但是我没有找到任何改变所有布局的标签,我只想改变文字大小,而不是改变背景或类似的东西,我像这样添加我的标签:
tabHost.addTab(tabHost.newTabSpec("photos_tab").setIndicator(getString(R.string.userPhotos)).setContent(R.id.tab2));
Run Code Online (Sandbox Code Playgroud)
当我尝试在setIndicator中放置TextView时,我可以更改文本大小但更改所有内容,单击,背景和其他内容..所以我只想更改文本大小.
有任何想法吗?
ps:我没有扩展TabActivity,因此我无法在AndroidManifest中更改Theme或类似的东西.(我之前尝试过:如何在android中更改tabhost的字体大小)
谢谢.
这是我的xml:
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是托管片段.
public class TabPractice extends Fragment{
private FragmentTabHost mTabHost;
//Mandatory Constructor
public TabPractice() {
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tabs_practice,container, false);
mTabHost = (FragmentTabHost)rootView.findViewById(android.R.id.tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("Practice All").setIndicator("Practice All"),
WelcomeScreen.class, null);
mTabHost.addTab(mTabHost.newTabSpec("Practive Fav").setIndicator("Practive Fav"),
FavoriteList.class, null);
return rootView;
}
Run Code Online (Sandbox Code Playgroud)
}
这就是我的标签看起来的样子,我不知道如何设置这些标签的样式.在解释样式的大多数示例中,有一个XML格式的TabWidget,当我尝试在我的布局中添加它时它不起作用.
1)有人可以帮助我理解如何在Fragment中托管FragmenttabHost(mycode-来自某些教程)与在FragmentActivity中托管它有什么不同?
2)如何在代码中设置选项卡样式?
谢谢.
android android-style-tabhost android-fragments android-styles
像android的联系人中的标签,我想添加样式(或者可能是背景或我不知道的东西)请问怎么样?
<?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">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)
你能告诉我在哪里可以找到好的背景或标签因为我不擅长设计:)