2016-05-04 7 views
1

Ich habe einen cardview mit dem folgenden Aufbau:Cardview ist nicht seine volle Breite unter (um 2% von links abgeschnitten wird)

- Main Relative Layout 
-- Header Container (Linear) 
-- Body Container (Linear) 
-- Footer Container (Linear) 

Die cardview von links um 2% abgeschnitten werden, ist es nicht die volle Breite, können Sie sagen, indem Sie den Rand (Radius) und den Unterschied zwischen der Karte und dem Ende vergleichen.

Screenshot: HERE.

Mein Layout:

<?xml version="1.0" encoding="utf-8"?> 

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

<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:id="@+id/cardView" 
    android:foreground="?attr/selectableItemBackground" 
    android:stateListAnimator="@anim/lift_on_touch"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:id="@+id/linearLayout2" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_marginTop="5dp" 
      android:layout_marginStart="5dp" 
      android:layout_marginEnd="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginLeft="5dp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="start" 
       android:gravity="start" 
       android:textSize="15dp" 
       android:text="Test League" 
       android:id="@+id/league" 
       android:layout_margin="5dp" /> 


      <View 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:background="#32000000" 
       android:layout_gravity="center" 
       android:layout_marginStart="8dp" 
       android:layout_marginEnd="8dp" 
       android:layout_marginRight="8dp" 
       android:layout_marginLeft="8dp" /> 

     </LinearLayout> 

     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5dp" 
      android:id="@+id/match_container" 
      android:layout_alignLeft="@+id/linearLayout2" 
      android:layout_below="@+id/linearLayout2"> 

      <RelativeLayout 
       android:orientation="vertical" 
       android:layout_width="0dp" 
       android:layout_weight="0.3" 
       android:layout_height="wrap_content" 
       android:id="@+id/first_team_container"> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:gravity="center" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="15dp" 
        android:id="@+id/first_team_icon" 
        android:layout_alignParentTop="true" 
        android:layout_centerHorizontal="true" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="First Team" 
        android:gravity="center" 
        android:textSize="13sp" 
        android:id="@+id/first_team_title" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true" 
        android:layout_below="@+id/first_team_icon" /> 
      </RelativeLayout> 

      <RelativeLayout 
       android:orientation="horizontal" 
       android:layout_width="0dp" 
       android:layout_weight="0.1" 
       android:layout_height="100dp" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/first_team_container" 
       android:layout_toEndOf="@+id/first_team_container" 
       android:id="@+id/match_result"> 


       <LinearLayout 
        android:orientation="horizontal" 
        android:layout_width="match_parent" 
        android:gravity="center" 
        android:layout_height="match_parent"> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textSize="20sp" 
         android:id="@+id/first_result" 
         android:layout_gravity="center_vertical" /> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="-" 
         android:textSize="20sp" 
         android:layout_marginLeft="5dp" 
         android:layout_marginRight="5dp" 
         android:layout_marginEnd="5dp" 
         android:layout_marginStart="5dp" 
         android:id="@+id/dash" 
         android:layout_gravity="center_vertical" /> 


        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textSize="20sp" 
         android:id="@+id/second_result" 
         android:layout_gravity="center_vertical" /> 

       </LinearLayout> 
      </RelativeLayout> 

      <RelativeLayout 
       android:orientation="vertical" 
       android:layout_width="0dp" 
       android:layout_weight="0.3" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/match_result" 
       android:layout_toEndOf="@+id/match_result" 
       android:id="@+id/second_team_container"> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:gravity="center" 
        android:layout_marginTop="15dp" 
        android:layout_alignParentTop="true" 
        android:layout_centerHorizontal="true" 
        android:layout_height="wrap_content" 
        android:id="@+id/second_team_icon" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Second Team" 
        android:gravity="center" 
        android:textSize="13sp" 
        android:id="@+id/second_team_title" 

        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true" 
        android:layout_below="@+id/second_team_icon" /> 

      </RelativeLayout> 

     </LinearLayout> 

     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:id="@+id/info_container" 
      android:layout_below="@+id/match_container" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_marginBottom="5dp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Status"   android:textSize="12sp" 

       android:id="@+id/status" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_marginStart="10dp" 
       android:layout_marginLeft="10dp" 
       android:textSize="12sp" 
       android:layout_height="wrap_content" 
       android:text="Date" 
       android:id="@+id/date" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginStart="10dp" 
       android:layout_marginLeft="10dp" 
       android:textSize="12sp" 

       android:text="Time" 
       android:id="@+id/time" /> 
     </LinearLayout> 

    </RelativeLayout> 

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

</RelativeLayout> 
+0

Ist Ihr Reallativ in einem anderen Layout? –

+0

Was möchten Sie hier erreichen? –

+0

Rand entfernen 10 dp –

Antwort

4

In Ihrem CardView Entfernen Sie diese Zeile android:layout_margin="10dp"

<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/cardView" 
    android:foreground="?attr/selectableItemBackground" 
    android:stateListAnimator="@anim/lift_on_touch"> 

Update:

hinzufügen android:padding="10dp" Mutter relativelayout von cardview.

+2

@VereeshCharantimath es hat nicht diese android: layout_margin = "10dp" –

+2

Was meinst du damit? Die cardview in der Frage hat android: layout_margin = "10dp", aber meine Antwort hat das nicht –

+0

Sorry meine schlechte! Habe nicht bemerkt, dass du Remove bedeutet –