I want two white lines -one on top of the view ,and the other one on
the bottom the view!!!
no left and right borders!!!!!
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
<stroke android:width="0.1dp" android:color="#FFFFFF" />
<corners android:radius="5dp"/>
<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" />
</shape>
I get a rectangle shaped view with white border,and transparent background.
But i want only the top and bottom lines of rectangle ,and not left and right lines of rectangle .
I want a view with border only on top and bottom,that will seem like sandwiched between two thin lines?
Try using <layer-list>. Check this below
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Border -->
<item>
<shape android:shape="rectangle">
<solid android:color="COLOR_OF_BORDER" />
</shape>
</item>
<!-- Rest of the drawable -->
<item>
<shape android:shape="rectangle">
<solid android:color="COLOR_OF_REST" />
<padding
android:bottom="2dp"
android:top="2dp" />
</shape>
</item>
</layer-list>
Related
I have a shape rectangle in my drawable like this
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="2dp"
android:topRightRadius="0dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp"/>
<stroke
android:width="1dp"
android:color="#android:color/white"
/>
</shape>
How, can I hide bottom line ?
<?xml version="1.0" encoding="UTF-8"?>
<!-- inset is used to remove border from top, it can remove border from any other side-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetTop="-2dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:id="#+id/rectangle">
<stroke android:width="1dp" android:color="#b7b7b7" />
<corners android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp"/>
<solid android:color="#454444"/>
</shape>
</inset>
use this code
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- the line -->
<item>
<shape>
<solid android:color="#yourColor"
/>
</shape>
</item>
<!-- This is full view -->
<item android:bottom="10dp">
<shape>
<solid android:color="#backGroundColor" />
</shape>
</item>
this will add a 10dp height line at bottom of your view , u can change size of the line with
<item android:bottom="10dp">
and change color too
good luck
How can i create an android layerlist drawable which gives me something like this
I have managed to generate just the outer circle only with the below code.But can seem to find a way to add the solid one inside.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="2dp"
android:color="#1582AF"/>
</shape>
Your layer list is look like below:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <!--Your outer blue border shape-->
<shape android:shape="oval">
<solid android:color="#android:color/white" />
<size
android:width="40dp"
android:height="40dp" />
<stroke
android:width="2dp"
android:color="#1582AF" />
</shape>
</item>
<!--Your inner blue Solid circle shape-->
<item android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp">
<shape android:shape="oval">
<solid android:color="#1582AF" />
</shape>
</item>
</layer-list>
Output:
I want to remove the peach solid color from interior portion and just want it at the border of top, left and right. The bottom color red is fine. I searched everywhere but they only suggested to use solid to overlap the whole red border.
XML Code
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<!-- Draw a 2dp width border around shape -->
<stroke
android:color="#ff1e0c"
android:width="2dp"
/>
</shape>
</item>
<!-- Overlap the left, top and right border using background color -->
<item
android:bottom="2dp"
>
<shape android:shape="rectangle">
<solid android:color="#fffbce"/>
</shape>
</item>
</layer-list>
try this solution,
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the line -->
<item android:bottom="1dp">
<shape>
<solid android:color="#00000000" />
<stroke
android:width="1dp"
android:color="#FF0000" />
</shape>
</item>
<item
android:bottom="-1dp"
android:left="0dp"
android:top="0dp">
<shape>
<solid android:color="#00000000" />
<stroke
android:width="1dp"
android:color="#000000" />
</shape>
</item>
</layer-list>
How can i make my edit text have a background with that blue border at the bottom, left and right sides where left and right side border has (let say) a height of 2dp ?
I have tried using layelist but all it's hard to get left and right border like the one at the image
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape >
<solid android:color="#android:color/holo_blue_bright"/>
<size android:height="1dp"/>
</shape>
</item>
<item android:bottom="5dp" android:left="5dp" android:right="5dp">
<shape>
<solid android:color="#android:color/black"/>
</shape>
</item>
This is what i get
Hi in most cases to have this type of background developers use 9.png graphics, you can generate background on this site.
http://android-holo-colors.com/
I tried and this worked for me.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="#android:color/holo_blue_bright" />
<size android:width="5dp" />
</shape>
</item>
<!-- main color -->
<item
android:bottom="1.5dp"
android:left="1.5dp"
android:right="1.5dp">
<shape>
<solid android:color="#android:color/black" />
</shape>
</item>
<!-- draw another block to cut-off the left and right bars -->
<item android:bottom="5.0dp">
<shape>
<solid android:color="#android:color/black" />
</shape>
</item>
</layer-list>
try this way and set as background
<?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="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="0.5dp"
android:color="#android:color/black" />
</shape>
</item>
</layer-list>
set to your Edittext as background
<EditText
android:id="#+id/editTextone"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="#drawable/edtbg"
/>
I use button with Font Awesome. When I try to set borders only on three sides of button, I see that border is all around my button. Here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="1dip" android:bottom="1dip" android:left="1dip"><shape>
<solid android:color="#efeae0" />
<stroke android:width="1dp" android:color="#d5cfc3" />
<corners android:topLeftRadius="15dp" />
</shape></item>
</selector>
How can I remove border from right side of button?
i am create button using below tool may useful to you :)
http://angrytools.com/android/button/
see this solution
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the line -->
<item android:top="-2dp" android:left="-2dp" android:bottom="-2dp">
<shape>
<solid android:color="#android:color/transparent" />
<stroke android:width="2dp" android:color="#21610B" />
</shape>
</item>
</layer-list>
Try out the below code to set the border in your 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="#FF0000" />
<padding
//android:bottom="10dp" Remove this to avoid seeing the bottom border
android:left="10dp"
android:right="10dp"
//android:top="10dp" Remove this to avoid seeing the top border
/>
<corners android:radius="5dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<solid android:color="#666666" />
</shape>
</item>
</layer-list>