2016-01-13 4 views
0

Панель инструментов видна в андроиде 4.4 и предыдущей версии. Когда я устанавливаю свое приложение в леденцовую версию, панель инструментов скрывается в макете фрейма. Как решить эту проблему?Панель инструментов не видна в леденец?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 
    <android.support.v4.widget.DrawerLayout  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/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     tools:openDrawer="hide"> 
     <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
    android:orientation="vertical"> 
      <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/white" 
     app:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    > 
</android.support.v7.widget.Toolbar> 

<FrameLayout 

    android:id="@+id/content_frame" 
    android:layout_below="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

Java код:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 
    getSupportActionBar().setDisplayShowTitleEnabled(false); 
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    getSupportActionBar().setDisplayShowCustomEnabled(true); // enable overriding the default toolbar layout 
    getSupportActionBar().setDisplayShowTitleEnabled(false); 
+0

податливость margin top to your layout layout, а затем попробуйте –

+0

вы можете добавить 'android: layout_height =" wrap_content " android: minHeight ="? attr/actionBarSize "' Toolba r –

+1

Я пробовал эту логику. Я отлично работаю в kitkat, но не работает в lollipop – Gopal

ответ

1

Try ниже код -

<android.support.v4.widget.DrawerLayout 
    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/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="hide"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/colorPrimary" 
      app:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

     <FrameLayout 

      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     </LinearLayout> 
    </android.support.v4.widget.DrawerLayout> 

Создание стилей под Рез/ценности-v21/style.xml

<resources> 

<style name="AppTheme.NoActionBar"> 
<item name="windowActionBar">false</item> 
<item name="windowNoTitle">true</item> 
<item name="android:windowDrawsSystemBarBackgrounds">true</item> 
<item name="android:statusBarColor">@android:color/transparent</item> 
</style> 

</resources> 
+0

Нет. Это не работает. Это прекрасно в kitkat. – Gopal

+0

@Gopal: можете ли вы отправить изображение с разницей? – kevz

+0

да. Я размещаю его – Gopal

1

Изменение корневой макет RelativeLayout и поставить FrameLayout первый и все остальное приходит после FrameLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

    <FrameLayout 

    android:id="@+id/content_frame" 
    android:layout_below="@+id/aaa" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

    <android.support.v4.widget.DrawerLayout  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/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     tools:openDrawer="hide"> 
     <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
    android:orientation="vertical"> 
      <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/white" 
     app:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    > 
</android.support.v7.widget.Toolbar> 
+0

Нет, он не работает в версии с леденцом. – Gopal

0

сделать его похожим на это я надеюсь, что он работает

<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" 
     app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/> 

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