Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove double Tool/Actionbar?

i don´t know why this second Toolbar appears...

I have attached my xml files for the Activit "ListActivity".

After deleting one line in the XML the doublebar were gone in the Deign Preview in Android Studio, but when i run the App the second bar appears still...

how to remove it?

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>

Thanks for Help!

like image 465
skm Avatar asked Mar 16 '17 14:03

skm


2 Answers

You have to disable ActionBar. Follow below procedures.

Add a theme to the style.xml :

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

Apply theme to Manifest in your activity tag:

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

Finally, set Toolbar as support ActionBar in onCreate:

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

Hope this helps.

like image 101
tahsinRupam Avatar answered Oct 06 '22 01:10

tahsinRupam


You should remove the theme ActionBar. Use this theme in your activity:

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

on manifest:

<application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
...
like image 24
mcatta Avatar answered Oct 06 '22 01:10

mcatta