2016-12-03 7 views
1

В настоящее время я занят просмотром деталей. Теперь мне стало интересно, как я могу сделать вид картона похожим на тот, который я разработал. Я не могу найти в Google, как это сделать. Я хочу, чтобы карта была разноцветной: 25% верхней части должно быть белым, а остальные 75 штук на дне должны быть красного цвета. Как я могу это сделать? Я думал о чертежах, но я думаю, что это будет выглядеть уродливо с разными телефонами.Кард с несколькими цветами фона

Я хочу, чтобы выглядеть следующим образом:

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> 

 Смежные вопросы

  • Нет связанных вопросов^_^