我一直在尝试更改主题为TabHost
。到目前为止,我已经得到了到这里:如何将TabHost的主题从Holo.Light更改为Dark主题
我已经使用以下XML来实现这一点:
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/signupLinearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0"
android:gravity="center"
android:orientation="horizontal" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0" >
<ScrollView
android:id="@+id/scrollView02"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ScrollView>
<ScrollView
android:id="@+id/scrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ScrollView>
</FrameLayout>
</LinearLayout>
我MainActivity.java
:
ContextThemeWrapper wrapper = new ContextThemeWrapper(
ActivityMain.this,
android.R.style.Theme_Holo_Light);
final LayoutInflater inflater = (LayoutInflater) wrapper
.getSystemService(LAYOUT_INFLATER_SERVICE);
dialog = new Dialog(wrapper);
dialog
.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog
.setContentView(R.layout.dialog_layout);
TabHost tabs = (TabHost) dialog
.findViewById(android.R.id.tabhost);
tabs.setup();
tabs.setCurrentTab(0);
TabSpec tspec1 = tabs.newTabSpec("Tab1");
tspec1.setIndicator("SIGN UP");
tspec1.setContent(R.id.scrollView02);
tabs.addTab(tspec1);
TabSpec tspec2 = tabs.newTabSpec("Tab2");
tspec2.setIndicator("LOG IN");
tspec2.setContent(R.id.scrollView01);
tabs.addTab(tspec2);
正如我使用Dialog
类在对话框中查看和整合TabHost
,这就是为什么我使用ContextThemeWrapper
为此在Dialog
上有一些主题。
现在,我的问题是,我该如何将Holo.Light
主题更改为Dark
主题。这里是我想要的图片:
我知道android并没有Holo.Dark
这个主题。这仅适用于ActionBars
。那么我怎样才能实现这个解决方案。
任何形式的帮助将不胜感激。
我会建议保持布局资源和代码分开。应该在布局文件中定义颜色和样式以获得更清晰的代码。 –