-1

Я также добавил соответствующий контент и activity.xml. Когда я запускаю приложение в студии Android на своем телефоне, я не вижу этого дополнительного бара. Но все же мне интересно, почему я вижу это, когда открываю его в своем редакторе?Почему мой фрагмент показывает дополнительную панель под панелью инструментов?

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

Пожалуйста, пост код активности. –

+0

@MavyaSoni Сделано. – user3705478

+0

также добавить свою тему? другой код правильный. –

ответ

0

Изменение темы в редакторе же, как и ваш манифест для деятельности, что вы работаете, и это должно исправить вашу проблему.

0

Использование Ниже Стиль, Это работает для меня:

<!-- 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

Редактировать свой styles.xml в

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
Смежные вопросы