Android Program : Design following-add a border to an Android Layout

 






Design following-add a border to an Android Layout


Soln :

Line.xml



<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp"/>
<padding android:left="20dp" android:right="20dp" android:top="20dp" android:bottom="20dp"/>
<solid android:color="#CCCCCC"/>
</shape>



activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/line">

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Hello World!"
android:background="#A00000FF"
android:gravity="center_vertical|center_horizontal"
android:textColor="#ffffff"
android:textSize="40sp" />
</LinearLayout>

</RelativeLayout>


Screenshot








Post a Comment

0 Comments