试图移动我的东西Toolbar而不是动作栏,但我不断收到错误说
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tyczj.weddingalbum/com.xxx.xxx.MainActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. …Run Code Online (Sandbox Code Playgroud) android android-actionbar material-design android-5.0-lollipop android-toolbar
我正在从我的应用程序迁移ActionBar到Toolbar.但我不知道如何在Back Arrow上显示和设置click事件Toolbar就像我一样Actionbar.

有ActionBar,我打电话mActionbar.setDisplayHomeAsUpEnabled(true).但是没有像这样的类似方法.
有没有人遇到这种情况,并以某种方式找到了解决它的方法?
android android-actionbar android-actionbar-compat android-toolbar
我正在尝试找出使用自定义字体作为工具栏标题的正确方法,并将其置于工具栏中(客户端要求).
目前,我正在使用旧的ActionBar,我将标题设置为空值,并使用setCustomView自定义字体TextView并使用ActionBar.LayoutParams将其居中.
有没有更好的方法呢?使用新工具栏作为我的ActionBar.
android android-layout android-theme android-styles android-toolbar
如何使用Android SDK API 21版(支持库)删除新工具栏中的额外填充?
我在谈论这张照片上的红色箭头:

这是我正在使用的代码:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="?attr/colorPrimary"
android:padding="0dp"
android:layout_margin="0dp">
<RelativeLayout
android:id="@+id/action_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:padding="0dp"
android:background="#000000">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
</Toolbar>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我已将所有相关填充设置为0,但Spinner周围仍有填充.我做错了什么或者我需要做些什么才能摆脱额外的填充?
编辑 有些人质疑我为什么要这样做.
根据材料设计规格,旋转器应距离左侧72dp 
我需要中和Google为了正确放置我的微调器而放置的填充: 
编辑2
根据Chris Bane在下面的回答,我将contentInsetStart设置为0.对于支持库,您需要使用app命名空间:
<android.support.v4.widget.DrawerLayout
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">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="@dimen/action_bar_height"
android:background="?attr/colorPrimary"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我希望这对某人有所帮助,让我困惑了好几天.
在谷歌推出Material Design之后,我听说过一个名为Toolbar的新小部件类.
什么是工具栏,ActionBar和ToolBar之间的确切区别是什么?
我正在使用Lollipop和AppCompat-v7库中引入的新添加的工具栏.我按照本指南设置了工具栏我注意到当你调用一些会调出上下文ActionBar的内容(例如突出显示复制/粘贴的文本)时,它会将工具栏向下推到页面上.您可以在页面底部的图像中看到我在说什么:
所以,基本上,我这样设置它.我在xml文件中定义了工具栏,我使用包含标签:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"/>
Run Code Online (Sandbox Code Playgroud)
然后,我在我的视图中实例化它:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/root"
tools:context=".MainActivity">
<include
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<!-- Rest of view -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在代码中,我这样设置:
// On Create method of activity:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Run Code Online (Sandbox Code Playgroud)
有没有人知道怎么做才能让Contextual ActionBar超越工具栏?

android android-appcompat android-5.0-lollipop android-toolbar
我有以下布局:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
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">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我添加了Fragments FrameLayout,替换它们.我的一个Fragment的一个是列表,它具有以下布局:
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
Run Code Online (Sandbox Code Playgroud)
我的问题是工具栏是在列表上绘制的.我试图通过将内容包装CoordinatorLayout成a LinearLayout来解决这个问题,这解决了透支问题,但这样appbar滚动行为就不再起作用了.
任何帮助深表感谢!
android android-toolbar androiddesignsupport android-coordinatorlayout
我正在使用支持库v21中的新工具栏更新我的应用程序.我的问题是,如果我没有设置"高程"属性,工具栏不会投射任何阴影.这是正常行为还是我做错了什么?
我的代码是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<FrameLayout
android:id="@+id/FrameLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent">
.
.
.
Run Code Online (Sandbox Code Playgroud)
在我的Activity - OnCreate方法中:
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
Run Code Online (Sandbox Code Playgroud) android material-design android-5.0-lollipop android-toolbar
我在一个活动我使用工具栏更改颜色Palette,但使用5.0的设备ActionBarActivity的status bar颜色是我的颜色colorPrimaryDark我的活动主题,所以我有2个非常不同的颜色和它看起来并不好.
我意识到在5.0你可以使用,Window.setStatusBarColor()但ActionBarActivity没有这个.
所以我的问题是在5.0中如何更改状态栏颜色ActionBarActivity?