2015-03-03 2 views
0

fragmenttabhost.xml являетсяtabdivider не работает на FragmentTabHost

<android.support.v4.app.FragmentTabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" /> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_weight="0" 
      android:layout_height="110dp" 
      android:showDividers="middle" 
      android:divider="@drawable/tab_divider" 
      android:layout_marginBottom="0dp" /> 

    </LinearLayout> 
</android.support.v4.app.FragmentTabHost> 

и tab_divider.xml является

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="line"> 
    <size 
     android:height="100px" 
     android:width="1dp" /> 
    <solid android:color="@color/red" /> 
</shape> 

любая помощь будет весьма заметным. Спасибо.

+0

вы проверяете на микросхемах? – Fahim

+0

no, lollipop bro – Gunaseelan

ответ

0

Вы можете добавить в явной separater таким образом

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     ImageView dividerImage = new ImageView(this); 
     dividerImage.setImageResource(R.drawable.tab_seperator); 

     TabHost tabHost = getTabHost(); 
     TabHost.TabSpec spec; 
     Intent intent; 

     intent = new Intent().setClass(this, Page1.class); 
     spec = tabHost.newTabSpec("page1").setIndicator(getLayoutInflater().inflate(R.layout.tab1, null)) 
        .setContent(intent); 
     tabHost.addTab(spec); 

     tabHost.getTabWidget().addView(dividerImage, LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); 

     intent = new Intent().setClass(this, Page2.class); 
     spec = tabHost.newTabSpec("page2").setIndicator(getLayoutInflater().inflate(R.layout.tab2, null)) 
        .setContent(intent); 
     tabHost.addTab(spec); 
    } 
Смежные вопросы