2016-02-20 183 views
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> 

回答

0

后测试其他背景颜色,发现该文本为黑色。这是它在黑色背景前不可见的唯一原因。

... aaaaand我又觉得很蠢!