2016-03-27 6 views

Antwort

1

Wenn Sie CardView innerhalb RelativeLayout wie folgt verwendet werden:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:background="@android:color/black" 
android:layout_height="match_parent"> 

    <android.support.v7.widget.CardView 
    ....> 
     <....>//Imagine a TextView here 
     <....> 
    </android.support.v7.widget.CardView> 
</RelativeLayout> 

dann werden Sie nicht in der Lage sein, die Elemente innerhalb des cardview in einem richtigen Weg zu arrrage.

Kurz vorstellen CardView als Halter, werden Sie ein Layout innerhalb CardView verwenden müssen, um es

zum Beispiel in korrekter Weise funktioniert:

<android.support.v7.widget.CardView 
    ....> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:background="@android:color/black" 
    android:layout_height="match_parent"> 
      <....>//Imagine a TextView here 
      <....> 
    </RelativeLayout> 
</android.support.v7.widget.CardView> 
1

Ja können wir verwenden, folgen Sie bitte die code:

<!-- About Panel --> 
<android.support.v7.widget.CardView 
    android:id="@+id/cv_About" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/cv_Help" 
    android:layout_gravity="center" 
    android:elevation="3dp" 
    app:cardCornerRadius="0dp" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:padding="@dimen/pad_20dp"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:text="@string/about" 
      android:textColor="@color/dimblack" 
      android:id="@+id/tvAbout" 
      /> 

    </RelativeLayout> 

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

Prost !!

Verwandte Themen