2015-07-25 3 views
13

Ich habe Probleme mit CardView Transparenz und card_elevation. ein CardView transparent um das Ergebnis zu verwenden versuchen, ist:Android CardView mit seltsamer Grenze, wenn transparent

enter image description here

Ohne Transparenz:

enter image description here

:

enter image description here

Was ich versuche, so etwas zu bekommen ist

Hier ist mein xml:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@mipmap/eifell" 
    android:padding="10dp" 
    tools:context=".MainActivity"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="5dp" 
     android:background="@android:color/transparent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.CardView 
       android:id="@+id/newsCardView" 
       android:layout_width="match_parent" 
       android:layout_height="175dp" 
       card_view:cardBackgroundColor="#602B608A" 
       card_view:cardElevation="5dp"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@android:color/transparent"> 
       </LinearLayout> 

      </android.support.v7.widget.CardView> 

     </LinearLayout> 
    </ScrollView> 

</RelativeLayout> 
+1

Haben Sie jemals eine Lösung für das nicht hilft, bieten bekommen? Es sieht so aus, als ob Karten keine Hintergrundtransparenz unterstützen: https://code.google.com/p/android/issues/detail?id=78061 –

+1

Hallo Steve, nein, ich verwende RelativeLayout nur mit einem transparenten Hintergrund ohne Schatten (Höhe). Wenn ich etwas gefunden habe, poste ich wo. – cRobot

+0

@SteveBlackwell Das ist gültige Antwort auf diese Frage. Vielen Dank. –

Antwort

5

diesen Code Versuchen:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <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:id="@+id/newsCardView" 
     android:layout_width="175dp" 
     android:layout_height="175dp" 
     card_view:cardBackgroundColor="#602B608A" 
     card_view:cardCornerRadius="0dp" 
     card_view:cardElevation="5dp"> 

    </android.support.v7.widget.CardView> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/imageView" 
     android:layout_gravity="left|top" 
     android:src="@drawable/fake_image" /> //REPLACE THIS WITH YOUR IMAGE 
</FrameLayout> 

enter image description here

Wenn es ganzen XML-Code Ihres Layout

+0

Alles sieht gut aus auf meinem Gerät, versuche, die cardView-Bibliothek auf com.android.support:cardview-v7:22.1.1 zu aktualisieren. –

+0

Ich benutze diese Version bereits, welche Android-Version hast du getestet? – cRobot

+0

Android 4.4.2 und Android 5.1.1 –