Is this image achievable through android drawable xml? - android

I'm trying to achieve the below image through Android xml
Right now I could just achieve this with help of some SOF q&a
Below are the code to achieve the above result
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="87%"
android:pivotY="140%">
<shape android:shape="rectangle">
<solid android:color="#color/lime_green_32CD32"/>
</shape>
</rotate>
</item>

Using below code, you can get something close to
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="35dp"
android:height="35dp"
android:top="7dp">
<rotate
android:fromDegrees="45"
android:pivotX="87%"
android:pivotY="140%"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#color/white" />
</shape>
</rotate>
</item>
<item
android:width="150dp"
android:height="50dp"
android:left="44.5dp">
<shape android:shape="rectangle">
<solid android:color="#color/white" />
</shape>
</item>
<item
android:width="10dp"
android:height="10dp"
android:left="35dp"
android:top="20dp">
<shape android:shape="oval">
<solid android:color="#color/white" />
</shape>
</item>
</layer-list>
</item>
<item android:top="2dp" android:bottom="2dp" android:right="2dp" android:left="2dp">
<layer-list>
<item
android:width="33dp"
android:height="33dp"
android:left="2dp"
android:top="6dp">
<rotate
android:fromDegrees="45"
android:pivotX="87%"
android:pivotY="140%"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#color/green" />
</shape>
</rotate>
</item>
<item
android:width="145dp"
android:height="46dp"
android:left="44.5dp">
<shape android:shape="rectangle">
<solid android:color="#color/green" />
</shape>
</item>
<item
android:width="10dp"
android:height="10dp"
android:left="35dp"
android:top="20dp">
<shape android:shape="oval">
<solid android:color="#color/white" />
</shape>
</item>
</layer-list>
</item>
</layer-list>

Related

how to Draw tooltip with border in android?

I am new to android and I wish to achieve a tooltip with border. Tooltip pointing to left.
i.e: like below with text of choice.
please help me with this, stuck with this for quite sometime now.
I was able to create a tooltip at top righ but how to get it in left ceter_verticle like the diagram.
my code looks like.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:gravity="top|right" android:right="10dp">
<rotate android:fromDegrees="45" android:toDegrees="0"
android:pivotX="50%" android:pivotY="0%" >
<shape android:shape="rectangle">
<size android:width="24dp" android:height="24dp" />
<stroke android:color="#android:color/holo_blue_bright" android:width="1dp"/>
</shape>
</rotate>
</item>
<item>
<shape android:shape="rectangle">
<size android:width="206dp" android:height="76dp" />
<solid android:color="#color/white"/>
<stroke android:color="#android:color/holo_blue_bright" android:width="1dp"/>
<corners android:radius="2dp" />
</shape>
</item>
<item android:gravity="top|right" android:right="10dp" android:top="1dp">
<rotate android:fromDegrees="45" android:toDegrees="0"
android:pivotX="50%" android:pivotY="0%" >
<shape android:shape="rectangle">
<size android:width="24dp" android:height="24dp" />
<solid android:color="#color/white"/>
</shape>
</rotate>
</item>
</layer-list>
Try the below code:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:left="16dp"
android:right="16dp"
android:top="17dp"
android:bottom="17dp">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
<corners android:radius="15dp" />
</shape>
</item>
<item
android:bottom="345dp"
android:right="360dp"
android:top="345dp">
<rotate
android:fromDegrees="-45"
android:pivotX="10%"
android:pivotY="10%"
android:toDegrees="0">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
</shape>
</rotate>
</item>
<item
android:bottom="350dp"
android:right="350dp"
android:top="350dp">
<rotate
android:fromDegrees="-45"
android:pivotX="1%"
android:pivotY="-5%"
android:toDegrees="0">
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</rotate>
</item>
<item
android:bottom="19dp"
android:left="19dp"
android:right="19dp"
android:top="19dp">
<shape android:shape="rectangle">
<solid android:color="#000000" />
<corners android:radius="15dp" />
</shape>
</item>
</layer-list>

Chat Bubble background Xml

I am trying create chat drawable background but not for chat just for view.Tried using some codes no able acheive fully as per the required. please help me to finish this.
Required image:
My code:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="45"
android:pivotX="0%"
android:pivotY="100%"
android:toDegrees="0" >
<shape android:shape="rectangle" >
<solid android:color="#color/colorWhite" />
</shape>
</rotate>
</item>
<item android:left="20dp">
<shape android:shape="rectangle" >
<solid android:color="#color/colorWhite" />
<corners android:radius="5dp" />
</shape>
</item>
try this
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="45"
android:pivotX="0%"
android:pivotY="10%"
android:toDegrees="0">
<shape android:shape="rectangle">
<solid android:color="#color/colorBlack" />
</shape>
</rotate>
</item>
<item
android:top="50dp">
<shape android:shape="rectangle">
<solid android:color="#color/colorWhite" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>

How can I create curved view?

I am working on cinema tickets application and now I need to create a curved view with blur shadow like this :
Is there a way of achieving this?
I have tried rotating image in x axis (-45%) but it is not what i need
as per #naggab's comment you should include image for this
but also I try to achieve this using below code
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="#color/white" />
<size
android:width="450dp"
android:height="110dp" />
</shape>
</item>
<item android:top="50dp">
<shape android:shape="rectangle">
<solid android:color="#color/colorPrimary" />
</shape>
</item>
<item android:top="20dp">
<shape android:shape="oval">
<solid android:color="#color/colorPrimary" />
<size
android:width="450dp"
android:height="110dp" />
</shape>
</item>
<item android:top="50dp">
<rotate
android:fromDegrees="4"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#color/colorPrimary" />
</shape>
</rotate>
</item>
<item android:top="50dp">
<rotate
android:fromDegrees="-4"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#color/colorPrimary" />
</shape>
</rotate>
</item>
</layer-list>

Radius in making border is given from inside instead of outside?

I am using below XML for creating border for a TextView.
<?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/dark_gray" />
</shape>
</item>
<item android:bottom="1dp">
<shape android:shape="rectangle">
<solid android:color="#color/dark_gray" />
</shape>
</item>
<item
android:bottom="2dp"
android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="#color/dark_gray" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="#color/white" />
<corners android:radius="#dimen/padding_4dp"/>
</shape>
</item>
</layer-list>
When I give radius as <corners android:radius="#dimen/padding_4dp"/>, it gives radius to corners but from inside, not from outside. So, as a result, corners remain sharp from outside. Like below:
Am I doing wrong somewhere?
Other items you have added in layer-list are missing corners, add it as below
<?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/dark_gray" />
</shape>
</item>
<item android:bottom="1dp">
<shape android:shape="rectangle">
<solid android:color="#color/dark_gray" />
<corners android:radius="#dimen/padding_4dp"/>
</shape>
</item>
<item
android:bottom="2dp"
android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="#color/dark_gray" />
<corners android:radius="#dimen/padding_4dp"/>
</shape>
</item>
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="#color/white" />
<corners android:radius="#dimen/padding_4dp"/>
</shape>
</item>
For the remaining two item also add a corner radius.

Android banner ribbon using shape

I am trying to figure out how I would stack shapes so I can create the following ribbon(Pink/White/Pink/White/Pink part). I will then be using this as a background for my textview.
I figured it out using a layer-list
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFe5887c" />
<size android:width="2dp" android:height="2dp"/>
</shape>
</item>
<item android:top="2dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFFFF" />
<size android:width="1dp" android:height="1dp"/>
</shape>
</item>
<item android:top="3dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFe5887c" />
<size android:width="20dp" android:height="20dp"/>
</shape>
</item>
<item android:top="23dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFFFF" />
<size android:width="1dp" android:height="1dp"/>
</shape>
</item>
<item android:top="24dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFe5887c" />
<size android:width="2dp" android:height="2dp"/>
</shape>
</item>
</layer-list>

Categories

Resources