Есть ли какой-нибудь возможный способ дизайна, как показано на рисунке ниже в Android? - PullRequest
0 голосов
/ 11 ноября 2018

Я хочу установить цвет фона на правой стороне, как показано на рисунке ниже. Как я мог это сделать?

enter image description here

1 Ответ

0 голосов
/ 12 ноября 2018

Создать файл для рисования XML

half_circle.xml

  <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:bottomLeftRadius="1000dp"
        android:topLeftRadius="1000dp"
        android:bottomRightRadius="0dp"
        android:topRightRadius="0dp" />
    <gradient
        android:startColor="#32aef4"
        android:centerColor="#44a0af"

        android:endColor="#79e2e2"
        android:angle="45"/>
</shape>

создать макет элемента в папке макета

item.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="5dp"
            android:text="sample"
            android:textSize="25sp"
            android:textColor="@android:color/black"/>

            <RelativeLayout
                android:layout_width="50dp"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:background="@drawable/half_circle">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_heart"
                android:layout_centerInParent="true"
                android:layout_margin="5dp"/>

            </RelativeLayout>

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

</RelativeLayout>

Вы можете достичь вышеуказанного.

P.S - пожалуйста, изучите, прежде чем публиковать вопрос в StackOverflow. Пожалуйста, ознакомьтесь с руководящими принципами

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...