Android - Background color with different colors and angles

I am trying to understand how to create this background in xml, could not find anything that helped me.

background

Ignore the image of the child’s circle and the text, of course, I'm talking about the background itself, is there a way to create something like this in xml?

Thanks in advance for any help. Hooray!

+5
source share
1 answer

I assume you are switched, but you can do this using vector drawings .

The following is not clear (the line is not completely straight), but you should start well:

New XML file:

<?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="100dp" android:width="100dp" android:viewportHeight="100" android:viewportWidth="100"> <path android:name="dark_triangle" android:fillColor="@color/blue" android:pathData="M 0,100 L 0,80 60,70 100,80 100,100 z" /> <path android:name="light_triangle" android:fillColor="@color/color_light_blue" android:pathData="M 60,70 L 100,65 100,80 z" /> </vector> 

In your layout:

 <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitCenter" app:srcCompat="@drawable/test" /> 

You may also need to add this to your layout:

  xmlns:app="http://schemas.android.com/apk/res-auto" 

Notes:

0
source

Source: https://habr.com/ru/post/1268657/


All Articles