好的,所以我正在制作一个带有标签的 android 应用程序,现在我的问题是标签小部件在不同的 android 版本或设备中并不统一。我想让它在任何 android 上都一样这是我的标签活动
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class Cook extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cook_layout);
TabHost tabHost = getTabHost();
// Tab for Snacks
TabSpec snackspec = tabHost.newTabSpec("Snacks");
// setting Title and Icon for the Tab
snackspec.setIndicator("Snacks", getResources().getDrawable(R.drawable.cook_icon_tab_snacks));
Intent snacksIntent = new Intent(this, Cook_tab_snacks.class);
snackspec.setContent(snacksIntent);
// Tab for Mains
TabSpec mainspec = tabHost.newTabSpec("Mains");
mainspec.setIndicator("Mains", getResources().getDrawable(R.drawable.cook_icon_tab_snacks));
Intent mainsIntent = new Intent(this, Cook_tab_mains.class);
mainspec.setContent(mainsIntent);
// Tab for Desserts
TabSpec dessertspec = tabHost.newTabSpec("Desserts");
dessertspec.setIndicator("Desserts", getResources().getDrawable(R.drawable.cook_icon_tab_snacks));
Intent dessertsIntent = new Intent(this, Cook_tab_desserts.class);
dessertspec.setContent(dessertsIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(snackspec); // Adding snacks tab
tabHost.addTab(mainspec); // Adding mains tab
tabHost.addTab(dessertspec); // Adding desserts tab
}
}
我也有我的 XML 布局:
<?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:background="@drawable/gradient_bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
我制作了一个新的指标 xml,它就像我关注的主要 android 选项卡指示器 v4 并搜索了很多博客,但我找不到我的答案......我真的想让所有 android 版本的 android 选项卡统一并制作颜色不错,因为橙色和黄色不适合我的应用程序中的颜色主题请帮助!!!!我似乎无法找到解决方法...干杯