Ich habe ein Problem mit der CardView
in der RecyclerView
. Mein CardView
wurde plötzlich schwarz und mein RatingBar
wurde blau. Ich verwende die InfiniteRecyclerView
, aber die Änderung auf die einfache RecyclerView
hat keine Auswirkungen. Ich kann die CardView
Hintergrundfarbe zu Weiß ändern, aber die RatingBar
wird noch blau sein. Dies ist ein Beispiel dafür, was passiert ist:CardView plötzlich schwarz
Ich verwende die normalen RecyclerView
in einer anderen Tätigkeit innerhalb eines Fragments mit dem gleichen Adapter und es sieht ganz gut. Hier ein Beispiel:
Dies ist die single_recipe_recycler_item.xml
Layout-Datei:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal">
<ImageView
android:id="@+id/recipe_recycler_image"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:src="@mipmap/ic_launcher" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp">
<!-- RealmRecipe Title -->
<TextView
android:id="@+id/recipe_recycler_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="end"
android:text="Very very very very very very long title"
android:textColor="@color/colorBlack"
android:textSize="@dimen/title"
android:textStyle="bold" />
<!-- Publisher -->
<TextView
android:id="@+id/recipe_recycler_publisher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/recipe_recycler_title"
android:layout_marginTop="5dp"
android:text="Publisher"
android:textColor="@color/colorBlack"
android:textSize="@dimen/genre"
android:textStyle="italic" />
<!-- Rating -->
<RatingBar
android:id="@+id/recipe_recycler_rating_bar"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/recipe_recycler_publisher"
android:layout_marginTop="5dp"
android:isIndicator="true"
android:max="5" />
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
Das ist mein AppTheme
:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Warum ist das passiert? Gibt es einen Fehler in CardView
? Irgendwelche Vorschläge, wie Sie das beheben können?
Welche Farbe hat 'selectableItemBackground' in Ihrem 'LinearLayout'? – Razor
Das ist Hintergrund, der für Welleneffekt drawable ist. CardView wurde schwarz, bevor ich "selectableItemBackground" anwendete, also ist das nicht der Grund für das Problem. – frozzyk
In welcher Android-Version testen Sie Ihre App? – Razor