您好我正在使用工具栏替换操作栏。
我尝试使用.xml文件。
在这个文件中,我尝试使用工具栏作为根布局。 我包括了support-v7-appcompat库。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/music_actionbar_display_home"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginRight="2dp"
android:weightSum="2" >
<ImageView
android:id="@+id/music_actionbar_backbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/home_back"
android:layout_weight="1"
android:layout_marginRight="2dp"
android:layout_gravity="center" />
<ImageView
android:id="@+id/music_actionbar_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/home_square_logo"
android:layout_weight="1"
android:layout_gravity="center" />
</LinearLayout>
<Spinner
android:id="@+id/music_actionbar_language"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:drawSelectorOnTop="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/music_actionbar_display_home"
android:spinnerMode="dialog" />
</android.support.v7.widget.Toolbar>
但是我收到以下错误。
Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
我做错了什么?