在我的應用程序中,我使用選項卡布局。我想要修改選項卡的默認高度,並且我想修改選項卡標籤字體而不使用自定義選項卡。可能嗎?如果是,那麼如何實施它。任何人都可以建議我如何設置標籤的高度以及如何在Android中設置標籤的字體?
public class HelloTabWidget extends TabActivity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost(); // The activity TabHost
addTab(tabHost,"Find Gifts","findgifts",R.drawable.findgifts,R.layout.tabs_bg);
}
public static void addTab(TabHost host, String title, String tag,
int drawable, int layout) {
TabHost.TabSpec spec = host.newTabSpec(tag);
spec.setContent(layout);
View view = prepareTabView(host.getContext(), title, drawable);
spec.setIndicator(view);
host.addTab(spec);
}
private static View prepareTabView(Context context, String title,
int drawable) {
View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
ImageView tabicon = (ImageView) view.findViewById(R.id.tabicon);
tabicon.setImageResource(drawable);
TextView tabtext = (TextView) view.findViewById(R.id.tabsText);
tabtext.setText(title);
return view;
}
}
跟蹤:
10-04 13:13:43.851: ERROR/AndroidRuntime(3734): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tab/com.example.tab.HelloTabWidget}:
java.lang.RuntimeException: Could not create tab content because could not find view with id 2130903042
10-04 13:13:43.851: ERROR/AndroidRuntime(3734): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
嗨,沒有使用自定義選項卡,這是不可能的權利? – naresh
是的,如果你想修改外觀,你必須使用某種形式的自定義。 – Reno
請參考提問一次 – naresh