2015-12-10 11 views
0

這是我在onCreate()函數中的代碼;通過在屏幕上使用垂直佈局Android Android Swipe Tabs沒有操作欄

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT); 
getSupportActionBar().setDisplayShowHomeEnabled(false); 
getSupportActionBar().setDisplayShowTitleEnabled(false); 

問題是,當我編寫和編譯這段代碼時,我無法得到我想在屏幕上看到的結果。我只想看到沒有操作欄的輕掃標籤。 這是圖像的結果; enter image description here

回答

0

刪除您的ActionBar並使用TabLayout。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical" android:padding="4dip" 
android:gravity="center_horizontal" 
android:layout_width="match_parent" android:layout_height="match_parent"> 

<android.support.design.widget.TabLayout 
    android:id="@+id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:tabMode="fixed" 
    app:tabGravity="fill" /> 

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="net.voidynullness.android.tabitytabs.TabLayoutActivity"> 

</android.support.v4.view.ViewPager> 

0

下的編輯資源的styles.xml - >數值 - > styles.xml並設置父父= 「Theme.AppCompat.Light.NoActionBar」

<resources xmlns:tools="http://schemas.android.com/tools"> 

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 

</style> 

</resources> 

和刪除

getSupportActionBar().setDisplayShowHomeEnabled(false); 
getSupportActionBar().setDisplayShowTitleEnabled(false); 
從活動

的的onCreate()

相關問題