Tôi muốn tạo bố cục xml mục thẻ cho CardView
và gặp phải lỗi này. Common solutions here không hoạt động (đã thử tất cả và những người khác từ các bài đăng tương tự).Android Studio: Hiển thị vấn đề Thiếu chủ đề kiểu chính xác được chọn cho bố cục này, Không tìm được kiểu có id
Đây là tôi xml
:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="4dp">
</android.support.v7.widget.CardView>
</RelativeLayout>
Đây là phần có liên quan của styles.xml
:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/primary_accent</item>
</style>
<!--Theme for Tool Bar (Action Bar)-->
<style name="ToolBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">@color/white</item>
</style>
Đây là phần có liên quan từ Manifest
:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
Đây là phần liên quan từ tập lệnh gradle build
:
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
Và đây là lỗi:
Cảm ơn,
thử thay đổi cấp api android trong khu vực xem trước. Hãy thử sử dụng cấp api 22. – Alex