我在Android預覽設計器中收到此錯誤消息爲「呈現問題」。我正在使用API 22來渲染並遷移到新的API支持v4:22.1+和v7:22.1+。在呈現過程中出現異常:查看android.support.v7.widget.Toolbar未使用正確的上下文創建
Rendering Problems Exception raised during rendering: View android.support.v7.widget.Toolbar not created with the right context
場景:
- 使用Android Studio中v1.2RC
- 渲染API V22(改變到21或19不解決它)
- 遷移ActivityBarActivity到AppCompatActivity
編譯部分:
compile 'com.android.support:support-v4:22.1.+' compile 'com.android.support:appcompat-v7:22.1.+'
工具欄
<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_height="?attr/actionBarSize" android:layout_width="match_parent" android:background="?attr/colorPrimary" android:elevation="4dp" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/Theme.AppCompat" />
你真的需要依靠IDE顯示 ?學習XML,您仍然可以自己構建UI。 –
完全使用您的IDE沒有任何問題。 OP從未說過他們用IDE在視覺上構建了UI。大多數情況下,他們只是試圖使用預覽功能,而這恰好是在UI中充實XML的最快方式。 – gMale