java - How do i add Toolbar to this layout? -


layout xml:

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@+id/drawer_layout"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <relativelayout         android:layout_width="match_parent"         android:layout_height="match_parent" >          <android.support.v4.view.viewpager             android:id="@+id/pager"             android:layout_width="match_parent"             android:layout_height="match_parent" />     </relativelayout>      <listview         android:id="@+id/drawer"         android:layout_width="120dp"         android:layout_height="match_parent"         android:layout_gravity="start"         android:background="#80000000"         android:choicemode="singlechoice"         android:divider="@android:color/transparent"         android:dividerheight="10dp" />  </android.support.v4.widget.drawerlayout> 

i'd add toolbar top of activity (similar actionbar) this:

<android.support.v7.widget.toolbar         android:id="@+id/toolbar"         android:minheight="?attr/actionbarsize"         android:background="#000000"         android:layout_width="match_parent"         android:layout_height="wrap_content">     </android.support.v7.widget.toolbar> 

it doesn't matter include view in layout (tried everywhere), inflateexception.

the appcompat-v7 library project (supposedly) handled eclipse, referenced library project, using latest (22.1.1) version. activity extends appcompatactivity (tried activity also).

no idea what's wrong, i'd appreciate advice. please tell if need more details.

create main xml like

<android.support.v4.widget.drawerlayout     android:id="@+id/drawer_layout"     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent">      <relativelayout         android:layout_width="match_parent"         android:layout_height="match_parent">         <android.support.v7.widget.toolbar             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:layout_height="?attr/actionbarsize"             android:background="#00ffee"             >         </android.support.v7.widget.toolbar>         <android.support.v4.view.viewpager             android:id="@+id/pager"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_below="@+id/toolbar"/>     </relativelayout>      <listview         android:id="@+id/drawer"         android:layout_width="120dp"         android:layout_height="match_parent"         android:layout_gravity="start"         android:background="#80000000"         android:choicemode="singlechoice"         android:divider="@android:color/transparent"         android:dividerheight="10dp"/>  </android.support.v4.widget.drawerlayout> 

add in styles.xml

<style name="apptheme" parent="theme.appcompat.light.noactionbar">         <item name="windowactionbar">false</item>         <item name="android:windownotitle">true</item>         <item name="colorprimary">@color/color_primary</item>         <item name="colorprimarydark">@color/color_primary_dark</item>         <item name="coloraccent">@color/color_accent</item>         <item name="android:textcolorprimary">@color/color_primary_text</item>     </style> 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -