0
如果我設置背景顏色,則標籤按鈕消失。事實上,只有在你按下它們時纔會看到它們。 試圖設置一個小的黑色圖像(循環),而不是「#000000」作爲背景。嘗試通過styles.xml設置主題背景,沒有奏效。嘗試在元素上「逐個部分」設置背景顏色,並單獨保留tabwidget。沒有工作。嘗試將Widget移到父ScrollView之外併爲ScrollView着色,但沒有奏效。背景顏色重疊標籤按鈕
MainActivity.java
public class MainActivity extends Activity {
[...]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost host = (TabHost)findViewById(R.id.tabHost);
host.setup();
TabHost.TabSpec spec = host.newTabSpec("First Tab");
spec.setIndicator("", getResources().getDrawable(R.drawable.paper_icon));
spec.setContent(R.id.tab1);
host.addTab(spec);
spec = host.newTabSpec("Second Tab");
spec.setIndicator("Second Tab", null);
spec.setContent(R.id.tab2);
host.addTab(spec);
spec = host.newTabSpec("Third Tab");
spec.setIndicator("Third Tab");
spec.setContent(R.id.tab3);
host.addTab(spec);
spec = host.newTabSpec("Fourth Tab");
spec.setIndicator("Fourth Tab");
spec.setContent(R.id.tab4);
host.addTab(spec);
}
[...]
}
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@drawable/black_back"
tools:context=".MainActivity">
<include layout="@layout/toolbar_logo"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="1">
<TabHost
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabHost"
android:layout_gravity="center_horizontal">
<LinearLayout
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"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/paper"/>
</TableLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/site"/>
</TableLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/athletic"/>
</TableLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tab4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/international"/>
</TableLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</ScrollView>