【发布时间】:2016-10-26 13:50:17
【问题描述】:
每当我将 CardView 放入我的 activity_main.xml 时,我都会收到此错误。
以下类无法实例化:
- android.support.v7.widget.CardView(打开类,显示异常,清除缓存)
我已将此添加到 build.gradle 中:
compile 'com.android.support:design:23.2.1'
//CardView
compile 'com.android.support:cardview-v7:25.0.0'
//RecyclerView
compile 'com.android.support:recyclerview-v7:25.0.0'
这是我的 activity_main.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.example.ivanp.meteostanica.TvrdjavaFragment"
android:orientation="vertical"
android:weightSum="1"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/bubanj"
android:id="@+id/imageView8"
android:adjustViewBounds="true" />
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:layout_margin="40dp"
android:id="@+id/card_view"
android:layout_width="fill_parent"
android:layout_height="250dp"
card_view:cardCornerRadius="2dp">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView" />
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
【问题讨论】:
标签: android android-layout android-studio android-cardview