We can design a linearlayout or relativelayout or framelayout... or even we can design a text view with this coding. The sample is given for linear layout, the result will be like this
here i had given corner radius for left top corner and left bottom corner for the linear layout, and i applied border for whole linearlayout.
For design the layout we need to use this xml file
layout_border.xml
and we need to set the xml file as background for the linear layout as
In the main xml
For gradient effect you can use the below xml, this will not be in the source, you can put this file and set this as background for gradient effect
layout_gradient.xml
here i had given corner radius for left top corner and left bottom corner for the linear layout, and i applied border for whole linearlayout.
For design the layout we need to use this xml file
layout_border.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<stroke android:width="2dp" android:height="2dp"
android:color="#FF0000" />
<solid android:color="#000000" />
<padding android:left="1dp" android:top="1dp" android:right="1dp"
android:bottom="1dp" />
<corners android:radius="1dp" android:bottomRightRadius="5dp"
android:bottomLeftRadius="0dp" android:topLeftRadius="5dp"
android:topRightRadius="0dp" />
</shape>
</item>
</layer-list>
and we need to set the xml file as background for the linear layout as
In the main xml
<LinearLayout android:layout_gravity="center" android:layout_width="200dp" android:layout_height="200dp" android:background="@drawable/layout_border" />
For gradient effect you can use the below xml, this will not be in the source, you can put this file and set this as background for gradient effect
layout_gradient.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#ffa5ba" android:endColor="#ff92af" android:angle="150"/> </shape>
Thanks
akm from cdacians(www.cdacians.com)
No comments:
Post a Comment