如何改变标签风格的Andr​​oid?

如何改变标签风格的Andr​​oid?

问题描述:

我想我的Andr​​oid标签看起来扁平,简单的像在官方Twitter的应用程序。我怎么能覆盖默认的(光)的主题和使用样式/主题定义更改背景图片的标签?

I'd like to my Android tabs to look flat and simple like the ones in the official TWitter app. How can I override the default (light) theme and change the background images for the tabs using style/theme definitions?

您可以通过调整code选项卡 - 这里是从我的应用程序的摘录,但你也可以直接分配,而不是主题的背景图像。 (我没有使用过的方式通过XML属性呢,不知道这是可用的,以及以某种方式)。

You could adjust the tabs via code - here's an excerpt from my application, but you could also assign themes instead of the background image directly. (I haven't used a way via xml attributes yet, not sure if that's available as well somehow).

private void initTabs() {
    tabs = (TabHost) findViewById(R.id.tabhost);
    tabs.setup();
    tabs.setBackgroundResource(R.drawable.bg_midgray);

   TabHost.TabSpec spec;

   // Location info
   txtTabInfo = new TextView(this);
   txtTabInfo.setText("INFO");
   txtTabInfo.setPadding(0, 5, 0, 0);
   txtTabInfo.setTextSize(11);

   txtTabInfo.setBackgroundResource(R.drawable.bg_tab_left_active_right_inactive);
   txtTabInfo.setTextColor(Color.DKGRAY);
   txtTabInfo.setGravity(Gravity.CENTER_HORIZONTAL);
   txtTabInfo.setHeight(39);
   spec = tabs.newTabSpec("tabInfo");
   spec.setContent(R.id.tabInfo);
   spec.setIndicator(txtTabInfo);
   tabs.addTab(spec);
   ...
}