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>
Related
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>
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>
I want to add tooltip up to my button. Is there any easy way to do this. I want to draw shape. But I only find methods with draw view or suggest to add lib.
Is it possible to draw tooltip(make tooltip with xml)?
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="12dp"
android:height="12dp"
android:gravity="bottom|center_horizontal">
<rotate
android:fromDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="45">
<shape android:shape="rectangle">
<corners android:bottomRightRadius="2dp"/>
<gradient
android:angle="0"
android:endColor="#cc00b8 "
android:startColor="#ef89ff "
android:type="linear" />
</shape>
</rotate>
</item>
<item
android:width="120dp"
android:height="36dp"
android:bottom="6dp">
<shape android:shape="rectangle">
<gradient
android:angle="0"
android:endColor="#cc00b8 "
android:startColor="#ef89ff "
android:type="linear" />
<corners android:radius="6dp" />
</shape>
</item>
</layer-list>
insert the width and height into a size tag so it will be usable in lower API levels:
<item android:gravity="bottom|center_horizontal">
<rotate android:fromDegrees="45" android:toDegrees="45"
android:pivotX="50%" android:pivotY="50%" >
<shape android:shape="rectangle">
<size android:width="12dp" android:height="12dp" />
<corners android:bottomRightRadius="2dp"/>
<gradient android:type="linear"
android:angle="0"
android:endColor="#color/gradient_red"
android:startColor="#color/gradient_red" />
</shape>
</rotate>
</item>
<item android:bottom="6dp">
<shape android:shape="rectangle">
<size android:width="120dp" android:height="36dp" />
<gradient android:type="linear"
android:angle="0"
android:endColor="#color/gradient_red"
android:startColor="#color/gradient_red" />
<corners android:radius="6dp" />
</shape>
</item>
<item
android:top="17dp">
<shape
android:shape="rectangle">
<solid
android:color="#FF7276" />
<corners
android:radius="8dp" />
<padding
android:top="17dp" />
</shape>
</item>
<item
android:width="24dp"
android:height="24dp"
android:end="32dp"
android:gravity="end"
android:top="-12dp">
<rotate
android:fromDegrees="45">
<shape
android:shape="rectangle">
<solid
android:color="#FF7276" />
</shape>
</rotate>
</item>
Try this, you will get perfect Tooltip shape in UI, after coping this code just check your UI(xml) or run the the program
enter image description here
I have fair Idea about layer_list referred from here and here
here is my code
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="#FEBB02" />
<corners android:radius="4dp" />
<size
android:width="40dp"
android:height="20dp" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="10dp"
android:right="10dp"
>
<rotate
android:toDegrees="45"
android:fromDegrees="45"
android:pivotX="50%"
android:pivotY="50%">
<shape android:shape="rectangle">
<solid android:color="#3F51B5" />
<corners android:radius="2dp" />
</shape>
</rotate>
</item>
This is how it is look line in studio
but when I am applying background of Linearlayout it gives this result
I am expecting corner would be below the pointed as seen in studio.
I think you should try setting the clipToPadding and clipChildren attributes to false, inside the parent view of the linear layout.
Plz change size of Linearlayout to 150dp * 100dp.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--<item>-->
<!--<scale android:drawable="#drawable/ic_launcher" android:useIntrinsicSizeAsMinimum="true">-->
<!--<!–<shape android:shape="rectangle" android:useLevel="true">–>-->
<!--<!–<solid android:color="#color/red" />–>-->
<!--<!–<size–>-->
<!--<!–android:width="60dp"–>-->
<!--<!–android:height="60dp" />–>-->
<!--<!–</shape>–>-->
<!--</scale>-->
<!--</item>-->
<item
android:bottom="15dp"
android:left="0dp"
android:right="0dp"
android:top="15dp">
<shape android:shape="rectangle">
<solid android:color="#FEBB02" />
<corners android:radius="4dp" />
<size
android:width="150dp"
android:height="70dp" />
</shape>
</item>
<item
android:bottom="15dp"
android:left="40dp"
android:right="40dp"
android:top="15dp"
>
<rotate
android:toDegrees="45"
android:fromDegrees="45"
android:pivotX="50%"
android:pivotY="50%">
<shape android:shape="rectangle">
<solid android:color="#3F51B5" />
<corners android:radius="2dp" />
<size
android:width="70dp"
android:height="70dp" />
</shape>
</rotate>
</item>
</layer-list>
Hi I wanted to use speech bubbles as background images for my app. I came across this posted here
Android drawable speech bubble
The example starts from the right direction I wanted to achieve this in the opposite direction I have tried
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:top="30dp">
<rotate
android:fromDegrees="-45"
android:pivotX="0%"
android:pivotY="0%"
android:toDegrees="0" >
<shape android:shape="rectangle" >
<solid android:color="#CCC" />
</shape>
</rotate>
</item>
<item android:right="10dp">
<shape android:shape="rectangle" >
<solid android:color="#CCC" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>
But I'm unable to get it to work, any help would be greatly appreciated!
Incoming message:
<?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="0%" >
<shape android:shape="rectangle">
<solid android:color="#color/chat_message_background_incoming" />
</shape>
</rotate>
</item>
<item android:left="20dp">
<shape
android:shape="rectangle">
<solid android:color="#color/chat_message_background_incoming"/>
<corners
android:radius="1dp"
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="5dp"
android:topRightRadius="15dp" />
</shape>
</item>
</layer-list>
Outgoing message:
<?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="100%"
android:pivotY="0%" >
<shape android:shape="rectangle">
<solid android:color="#color/chat_message_background_outcoming" />
</shape>
</rotate>
</item>
<item android:right="20dp">
<shape
android:shape="rectangle">
<solid android:color="#color/chat_message_background_outcoming"/>
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="5dp" />
</shape>
</item>
</layer-list>
Hopefully, it would help
incoming bubble shape background
<?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="100%"
android:pivotY="100%"
android:toDegrees="0" >
<shape android:shape="rectangle" >
<solid android:color="#color/colorSendMessageBg" />
</shape>
</rotate>
</item>
<item android:right="5dp">
<shape android:shape="rectangle" >
<solid android:color="#color/colorSendMessageBg" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>
outgoing bubble shape background
<?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/colorReciveMessageBg" />
</shape>
</rotate>
</item>
<item android:left="5dp">
<shape android:shape="rectangle" >
<solid android:color="#color/colorReciveMessageBg" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>
Final result