首页 > support.v7.widget.Toolbar 报错

support.v7.widget.Toolbar 报错

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

出现以下的错误

No resource found that matches the given name(at'minHeight'with value'?attr/actionBarSize') 
No resource found that matches the given name(at'theme'with value'@style/ThemeOverlay.AppCompat.Dark.ActionBar') 
No resource found that matches the given name(at'popupTheme'with value'@style/ThemeOverlay.AppCompat.Light') 

使用 support-v7 的几个步骤:

注意检查 Eclipse 布局预览的 样式是否是 appcompat_v7 定义过的样式.

<!-- 一段可用的布局代码 -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="#d8d8d8"
        android:minHeight="?attr/actionBarSize"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/toolBar"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />
    </LinearLayout>

</RelativeLayout>
【热门文章】
【热门文章】