2017-03-16 26 views
1

我不知道爲什麼這第二個工具欄出現...如何刪除雙Tool/Actionbar?

我附加了我的xml文件的Activit「ListActivity」。

刪除一行在XML中doublebar都不見了在屈尊預覽Android Studio中後,但是當我運行的應用程序出現在第二個欄還是......

如何去除呢?

enter image description here activity_list.xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="ibas.locatixteamviewer.ListActivity"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

</android.support.design.widget.AppBarLayout> 

<include layout="@layout/content_list" /> 

content_list.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/content_list" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/swipeRefreshLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.RecyclerView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" 
     android:id="@+id/itemRecyclerView" /> 

</android.support.v4.widget.SwipeRefreshLayout> 

感謝您的幫助!

+0

檢查此[鏈接](http://www.androhub.com/android-toolbar/)。 –

回答

4

您必須禁用ActionBar。遵循以下程序。

添加一個主題,以style.xml:

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

應用主題在你的活動標籤的體現:

<activity 
    android:name=".MainActivity" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme.NoActionBar"> 

最後,設置工具欄在的onCreate支持動作條:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
setSupportActionBar(toolbar); 

希望這會有所幫助。

+0

很好解釋。標記爲答案。 –

+0

我的榮幸,您可以將答案標記爲已接受。 :) – tahsinRupam

2

您應該刪除主題ActionBar。在活動中使用這個主題:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <!--<item name="windowActionModeOverlay">true</item>--> 
</style> 

在清單:

<application 
     android:allowBackup="true" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" 
...