Toolbar问题

2016-08-25  本文已影响0人  Jeeno

toolbar 设置paddingtop 一直报错

    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:minHeight="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        app:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
        android:paddingTop="@dimen/tool_bar_top_padding">
    <TextView
        android:id="@+id/toolbar_title"  
        style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" 
        android:textStyle="bold"
        android:textColor="@color/md_white_1000"
        android:text="@string/app_name"/>
    </android.support.v7.widget.Toolbar>

现以下错误

    FATAL EXCEPTION: main Process:
    android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.Toolbar
    Caused by: java.lang.reflect.InvocationTargetException
    Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1

错误来源:Can't convert to dimension: type=0x1 找不到dimension
原因 android:paddingTop="@dimen/tool_bar_top_padding" 只定义在values-21文件夹中, 到5.0以下系统运行时就会出现该错误

上一篇下一篇

猜你喜欢

热点阅读