I am trying to make the layout below (picture 1) like the one in the photo (picture 2) but I don't know how to implement it. Any ideas?
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Background -->
<item>
<shape android:shape="rectangle">
<solid android:color="#2b2c2e" />
<size android:height="100dp"
android:width="100dp"/>
</shape>
</item>
<!-- Curved shape -->
<item>
<shape
android:shape="rectangle">
<stroke
android:width="0.5dp"
android:color="#1d1d20" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="30dp"
android:topLeftRadius="150dp"
android:topRightRadius="10dp" />
<gradient
android:angle="45"
android:endColor="#1f5993"
android:centerColor="#316bb7"
android:startColor="#1f5993" />
</shape>
</item>
</layer-list>
Related
I want to make a drawable like this :
this is my code so far:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:topLeftRadius="10dp"
android:topRightRadius="5dp"
android:bottomLeftRadius="15dp"
android:bottomRightRadius="20dp" />
<solid android:color="#color/red_home" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<corners android:topLeftRadius="100dp"
android:topRightRadius="0dp"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp" />
<solid android:color="#color/green2" />
</shape>
</item>
</layer-list>
It's not how I wanted it to be ... I don't want the radius in the top left corner... how can I make it like the first image ?
I'm trying to replicate the following shape in Android studio:
I can't figure out how to do it in android drawable xml.
At the moment I used a layer-list where:
As the first item I placed a transparent (or white) rectangle, to which I gave a padding on the left side and vertically.
As the second item I placed a rectangle containing the gradient and the corners on the left.
Now, I don't know how I can make the two "reverse angles" on the right, I've tried everything but online there aren't many examples to refer.
Here's my current code:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#color/transparent" />
<padding
android:bottom="8dp"
android:left="8dp"
android:right="0dp"
android:top="8dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<gradient
android:angle="0"
android:endColor="#color/green"
android:startColor="#color/blue"
android:type="linear" />
<corners
android:bottomLeftRadius="22dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="22dp"
android:topRightRadius="0dp" />
</shape>
</item>
</layer-list>
How can I change the code to obtain this shape?
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="600dp"
android:height="400dp">
<shape android:shape="rectangle">
<gradient
android:angle="0"
android:endColor="#android:color/holo_green_light"
android:startColor="#android:color/holo_blue_light"
android:type="linear" />
</shape>
</item>
<item android:width="600dp"
android:height="100dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white" />
<corners android:bottomRightRadius="100dp" />
</shape>
</item>
<item android:width="600dp"
android:height="100dp"
android:top="300dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white" />
<corners android:topRightRadius="100dp" />
</shape>
</item>
<item android:width="200dp"
android:height="200dp"
android:top="100dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white" />
</shape>
</item>
<item android:width="600dp"
android:height="200dp"
android:top="100dp">
<shape android:shape="rectangle">
<gradient
android:angle="0"
android:endColor="#android:color/holo_green_light"
android:startColor="#android:color/holo_blue_light"
android:type="linear" />
<corners android:radius="100dp" />
</shape>
</item>
</layer-list>
Here is a preview image
try this
I want to add inner shadow effect into my drawable file like this.
Below is my drawable file. I want to achieve shadow inside the drawable file as you can see above. What changes should i make to achieve this?
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<item
android:bottom="#dimen/_3sdp"
android:left="#dimen/_8sdp"
android:right="#dimen/_8sdp"
android:top="#dimen/_3sdp">
<shape>
<corners android:radius="#dimen/_75sdp" />
<padding android:bottom="#dimen/_8sdp"
android:top="#dimen/_8sdp" />
<solid android:color="#color/leave_msg_color" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="#dimen/size_point5dp"
android:left="#dimen/size_point5dp"
android:right="#dimen/size_point5dp"
android:bottom="#dimen/size_point5dp">
<shape android:shape="rectangle">
<solid android:color="#color/blue_E7F1FF"/>
<corners android:radius="8dp"/>
</shape>
</item>
<!-- left shadow -->
<item>
<shape android:shape="rectangle">
<gradient
android:angle="180"
android:centerColor="#00FF0000"
android:centerX="0.98"
android:endColor="#5C000000"
android:startColor="#00FF0000" />
<corners android:radius="8dp" />
</shape>
</item>
<!-- right shadow -->
<item>
<shape android:shape="rectangle">
<gradient
android:angle="360"
android:centerColor="#00FF0000"
android:centerX="0.98"
android:endColor="#5C000000"
android:startColor="#00FF0000" />
<corners android:radius="8dp" />
</shape>
</item>
<!-- top shadow -->
<item>
<shape android:shape="rectangle">
<gradient
android:angle="270"
android:centerColor="#00FF0000"
android:centerY="0.1"
android:endColor="#00FF0000"
android:startColor="#6B000000" />
<corners android:radius="8dp" />
</shape>
</item>
<!-- bottom shadow -->
<item>
<shape android:shape="rectangle">
<gradient
android:angle="90"
android:centerColor="#00FF0000"
android:centerY="0.1"
android:endColor="#00FF0000"
android:startColor="#6B000000" />
<corners android:radius="8dp" />
</shape>
</item>
</layer-list>
The image would look like image
You can make many item inside your layer-list to produce shadow effect inside check this one out Add shadow to custom shape on Android.
You just need to change some values to achieve your wanted output. make the radius to get oval form and the values of colors.
I designed a custom shape
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="0dp"
android:left="30dp"
android:right="30dp"
android:top="-30dp">
<shape android:shape="rectangle">
<size
android:width="80dp"
android:height="40dp" />
<solid android:color="#color/colorPrimary" />
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<size
android:width="100dp"
android:height="40dp" />
<solid android:color="#color/colorPrimary" />
<corners android:radius="0dp" />
</shape>
</item>
</layer-list>
Now when I try to apply this to a layout background Which is BottomSheet it doesn't have any effect and simply covers up the entire screen with blue background (It becomes a solid flat blue rectangle)
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_features"
android:padding="32dp"
app:behavior_hideable="false"
app:behavior_peekHeight="#dimen/partial_features_peek_height_50dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
How can I apply this custom background in its shape
You can try it
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="0dp"
android:left="30dp"
android:right="30dp">
<shape android:shape="rectangle">
<size
android:width="80dp"
android:height="40dp"/>
<solid android:color="#color/colorPrimary"/>
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
</item>
<item
android:top="30dp"
>
<shape android:shape="rectangle">
<size
android:width="100dp"
android:height="40dp"/>
<solid android:color="#color/colorPrimary"/>
<corners android:radius="0dp"/>
</shape>
</item>
</layer-list>
Let me know the result if it is the layout which you want to achieve or not. Hope it help
use layer list
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Apply the margin value on the "item" element -->
<!-- This example creates a 15dp visible margin around the dialog -->
<item
android:top="15dp"
android:bottom="15dp"
android:left="15dp"
android:right="15dp">
<shape
android:shape="rectangle">
<!-- Add attributes specific to your background (e.g. corner radius, colors, etc.) -->
<!-- Set "padding" at minimum to match margin and add additional content padding as well, if desired -->
<!-- This example creates 10dp of internal padding for content -->
<padding
android:top="25dp"
android:bottom="25dp"
android:left="25dp"
android:right="25dp" />
</shape>
</item>
</layer-list>
I want to make like this. How to get exactly like this (see image below)? I tried layer-list but not able to get this view.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#afbdc3" />
<corners android:radius="10dp" />
</shape>
</item>
<item android:right="5px">
<shape android:shape="rectangle">
<solid android:color="#91a5af" />
<corners android:radius="10dp" />
</shape>
</item>
<item android:right="10px">
<shape android:shape="rectangle">
<solid android:color="#79919d" />
<corners android:radius="10dp" />
</shape>
</item>
</layer-list>
And so on
LIKE THIS LAYER