How can I create such borders of the button? [duplicate] - android

This question already has answers here:
Rounded corner for textview in android
(12 answers)
Closed 3 years ago.
Could not post it without a link ! sorry !

Use a layer list drawable, something like this :)
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="4dp"
android:top="4dp">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<stroke
android:width="1dp"
android:color="#color/gray" />
<solid android:color="#color/transparent" />
</shape>

Related

How to make rounded and bordered button android? [duplicate]

This question already has answers here:
Android button background is taking the primary color
(6 answers)
Closed 9 months ago.
I am making a rounded and bordered button. But I am getting button with only primary color in the theme.
Here is my code in circular button drawable file:-
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#color/green" />
<corners android:radius="50dp" />
<stroke
android:width="10dp"
android:color="#color/red_primary" />
</shape>
here is my button code:-
<Button
android:id="#+id/feedback_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="5dp"
android:layout_weight="1"
android:padding="10dp"
android:background="#drawable/circular_button"
android:text="#string/send_feedback"
android:textColor="#color/white" />
also add app:backgroundTint="#null" in Button tag.
you can use bewlo code for rounded and bordered button
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#color/BlueDark"/>
<stroke android:width="3dp" android:color="#color/White" />
<corners android:bottomRightRadius="30dp"
android:topRightRadius="30dp"
android:topLeftRadius="30dp"
android:bottomLeftRadius="30dp"/>
<padding android:left="0dp" android:top="0dp"
android:right="0dp" android:bottom="0dp" />
</shape>
Also YOU can set boder wedith with bewlo line
<stroke android:width="3dp" android:color="#color/White" />

Avoid ripple effect combine colors [duplicate]

This question already has an answer here:
How can I disable Android Lollipop ripple's alpha value?
(1 answer)
Closed 2 years ago.
I have a simple program that uses ripple effect using this code (edited from here):
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#0000ff"><!--blue-->
<item android:id="#android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#0000ff" /><!--blue-->
<corners android:radius="20dp" />
</shape>
</item>
<item android:id="#android:id/background">
<shape android:shape="rectangle">
<solid android:color="#ff0000"/><!--red-->
<corners android:radius="20dp" />
</shape>
</item>
</ripple>
everything works fine, but I want the ripple color (blue) to be above the background color (red) not combined with it into purple.
SCREENSHOT:
before:
in process:
after:
what I want to be after:
any way to achieve this?
Thanks in advance.
I have edited it a bit you can try this sample
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#0000ff">
<item>
<selector>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#android:color/transparent"/>
<corners android:radius="20dp" />
</shape>
</item>
<item android:state_pressed="false">
<shape android:shape="rectangle">
<solid android:color="#ff0000"/>
<corners android:radius="20dp" />
</shape>
</item>
</selector>
</item>
<item android:id="#android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#0000ff" />
<corners android:radius="20dp" />
</shape>
</item>
</ripple>

Android xml shape drawable [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to draw xml layout shape above showing image android.please help me
Try this:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke android:color="#80000000"
android:width="0.5dp"
/>
<corners
android:bottomLeftRadius="32dp"
android:topLeftRadius="32dp" />
</shape>
First of all try to show your progress or what you have tried so far and where you have got stuck.
Secondly for your question, use below code :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="10dp"
android:top="10dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/black" /> //change your desired color
//use can set your desired size to make curve
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="10dp"
android:topRightRadius="0dp" />
</shape>
</item>
Create this drawable and use in your xml
If you want only left two corners to be curved. Then just set bottomRightRadius & topRightRadius to 0dp
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#color/color_Transport_Grey" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="10dp"
android:topRightRadius="0dp" />
<padding
android:left="0dip"
android:right="0dip" />
</shape>
Your shape (fab.xml):
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="#color/main_light_extreme">
<item android:id="#android:id/mask">
<shape android:shape="oval">
<solid android:color="#color/main_light_extreme" />
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#color/main_normal" />
</shape>
</item>
</ripple>
Your image with shape background (ImageButton):
<ImageButton
android:id="#+id/fab"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="54dp"
android:layout_marginEnd="36dp"
android:background="#drawable/fab"
android:src="#android:drawable/ic_menu_camera" <!-- your need this -->
android:elevation="12dp" />
Result (Note: ripple works only android api >= 21 Lollipop):
Image above drawable shape :D

How to make Relative layout look like CardView [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have too many Relative layout and I want to convert it that's it look like card.How I can make drawable which look like Card.I want to make it Rectangle shape like a row.
Try this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:paddingRight="15dp"
android:background="#drawable/card_background"
android:descendantFocusability="afterDescendants" />
Make one drawable named card_background.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#CABBBBBB" />
<corners android:radius="2dp" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white" />
<corners android:radius="2dp" />
</shape>
</item>
</layer-list>
Add background to relative layout:
<?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="#CABBBBBB" />
<corners android:radius="2px" />
</shape>
</item>
<item
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/grey" />
<corners android:radius="2px" />
</shape>
</item>

Android drawable defined in xml [duplicate]

This question already has answers here:
Android - drawable with rounded corners at the top only
(10 answers)
Closed 9 years ago.
Is it possible to define a similiar rectangle like this:
<item android:id="#android:id/background">
<shape>
<gradient
android:angle="270"
android:endColor="#444444"
android:startColor="#666666" />
<corners android:radius="10dip" />
</shape>
</item>
</layer-list>
BUT ONLY the upper corners WITH radius, and the others without.
Cherck out this questions:
Rounded corners only on top
This is the answer:
<corners android:radius="1dp" android:topLeftRadius="6dp" android:topRightRadius="6dp" android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp"/>
Note that Eclipse chokes on this and will not display correctly in the view editor though,

Categories

Resources