2016-12-03 31 views
1

現在、詳細ビューページで忙しいです。私は今、私が設計したもののようなカードビューをどのように見せることができるのだろうと思っていました。私はそうする方法をGoogle上で見つけることができない。私はカードをマルチカラーにしたい:トップの25%は白で、残りの75プロットは赤でなければならない。どうすればいいですか?私はdrawablesについて考えていましたが、私はそれが別の携帯電話で醜いと思うと思います。複数の背景色を持つCardview

私はそれが次のようになりたい:

enter image description here

私はこのcardviewを持っている:

<android.support.v7.widget.CardView 
    android:id="@+id/view4" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="8dp" 
    android:layout_marginLeft="16dp" 
    android:layout_marginRight="16dp" 
    android:layout_marginTop="24dp"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/material_grey_50" 
     android:orientation="vertical"> 

     <TextView 
      style="@style/TextViewAppearance.Body3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="16dp" 
      android:layout_marginTop="16dp" 
      android:text="Descriptie" 
      android:textColor="?attr/colorPrimaryDark" /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:layout_marginLeft="8dp" 
      android:layout_marginRight="8dp" 
      android:layout_marginTop="8dp" 
      android:background="@color/material_grey_200" /> 

     <TextView 
      android:id="@+id/descriptionText" 
      style="@style/TextViewAppearance.Body2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="16dp" 
      android:layout_marginLeft="16dp" 
      android:layout_marginRight="16dp" 
      android:layout_marginTop="16dp" 
      android:textColor="@color/material_grey_600" /> 

    </LinearLayout> 

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

答えて

-1

あなたは線形レイアウトを追加することによってこれを行うことができ、親を埋めるために幅を設定し、背景色を設定します。

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:background="@color/black" 
    android:layout_marginTop="5dp"> 

    <TextView 
     android:id="@+id/descriptionText" 
     style="@style/TextViewAppearance.Body2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="16dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:layout_marginTop="16dp" 
     android:textColor="@color/material_grey_600" /> 
</LinearLayout> 
0

次のように重量とweightSumを使用してみてください:

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:weightSum="4"> 

    <TextView 
     style="@style/TextViewAppearance.Body3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginTop="16dp" 
     android:text="Descriptie" 
     android:textColor="?attr/colorPrimaryDark" 
     android:background="@color/material_grey_50" 
     android:layout_weight="1" /> 

    <TextView 
     android:id="@+id/descriptionText" 
     style="@style/TextViewAppearance.Body2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="16dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:layout_marginTop="16dp" 
     android:textColor="@color/material_grey_600" 
     android:layout_weight="3"/> 
    </LinearLayout>