Android Studio - rendering problems with library support

I had a problem with providing a layout preview in Android Studio when using classes from google support libraries (appcompat-v7, support-v4).

Example (the same applies to any other element from the support libraries):

The following classes were not found: - android.support.v7.widget.Toolbar (Fix Build Path, Edit XML, Create Class)

Libraries are added to the build.gradle dependency list:

dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.android.support:support-v4:22.1.1' } 

The fact is that when I change the class name in XML to <Toolbar> instead of <android.support.v7.widget.Toolbar> , everything renders fine, but it will not work in older versions of the API. Changing the version of the rendering API does not eliminate it, does not change the theme of the application, or does not create / clean up the project.

The application runs on the old and new APIs without any problems - this is just a rendering that annoys me, since I tried everything I found in Qaru regarding such problems, and I still could not fix it. It seems to me that the Android Studio layout renderer does not see the classes that are added to the dependency list.

Below is the code for my custom application toolbar:

 <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:paddingTop="@dimen/padding_top" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primaryColor" app:theme="@style/CustomToolbarTheme" /> 
+6
source share
1 answer

Look at the answer from Nadir Williams here . He said

It is not an attribute of a theme, which should be an android: now a theme instead of an application: theme?

Does it help?

0
source

Source: https://habr.com/ru/post/985913/


All Articles