-1

J'ai ajouté le contenu correspondant et le fichier activity.xml. Quand je cours l'application dans le studio android sur mon téléphone, je ne vois pas cette barre supplémentaire là. Mais je me demande encore pourquoi je vois ça quand je l'ouvre dans mon éditeur?Pourquoi mon fragment affiche-t-il une barre supplémentaire sous la barre d'outils?

enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/content_home" 
    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" 
    tools:context="com.a.a2.HomeFragment" 
    tools:showIn="@layout/activity_home"> 

</RelativeLayout> 

activity_home.xml

<?xml version="1.0" encoding="utf-8"?> 
<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="com.a.a2.Home"> 

    <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_home" /> 

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

content_home.xml

<fragment 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/fragment" 
    android:name="com.a.a2.HomeFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:layout="@layout/fragment_home" /> 

home.java

public class Home extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_snd_number_home); 
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 
     } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     getMenuInflater().inflate(R.menu.menu_snd_number_home,menu); 
     return true; 
    } 
} 

styles.xml

<resources xmlns:android="http://schemas.android.com/tools" xmlns:app="urn:oasis:names:tc:xliff:document:1.2"> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/actionMenuTextColor</item> 
     <item name="@android:windowLightStatusBar">true</item> 
    </style> 

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

    <style name="MyToolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar"> 
     <item name="android:textColorPrimary">#000000</item> 
    </style> 

    <style name="ToolbarTitle" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"> 
     <item name="android:textSize">20sp</item> 
    </style> 

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

    <style name="onOffSwitch" parent="Theme.AppCompat.Light"> 
     <!-- active thumb & track color (30% transparency) --> 
     <item name="colorControlActivated">#000000</item> 

     <item name="colorControlNormal">#9E9E9E</item> 

     <!-- inactive thumb color --> 
     <item name="colorSwitchThumbNormal">#9E9E9E</item> 

     <!-- inactive track color (30% transparency) --> 
     <item name="android:colorForeground">#42221f1f</item> 
    </style> 
</resources> 
+0

S'il vous plaît envoyer votre code d'activité. –

+0

@MavyaSoni Fait. – user3705478

+0

ajoutez aussi votre thème? l'autre code est correct. –

Répondre

0

Changer votre thème dans l'éditeur même que celui de votre manifeste pour l'activité que vous travaillez et qui devrait résoudre votre problème.

0

utilisation ci-dessous style, Cela fonctionne pour moi:

<!-- Base application theme. --> 
    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorPrimary</item> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 
0

Modifier votre styles.xml comme

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">