. .
//first create layout xml in layout folder in my case it
//sample_activity.xml below is the xml code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_centerInParent="true"
android:text="This is button"/>
</RelativeLayout>
. , . , .
. ( ), ( ), - ( ), -xlarge ( ). dimens.xml .
, /dimens.xml .
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="button_width">100dp</dimen>
<dimen name="button_height">50dp</dimen>
</resources>
-large/dimens.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="button_width">200dp</dimen>
<dimen name="button_height">100dp</dimen>
</resources>
- small/dimens.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="button_width">10dp</dimen>
<dimen name="button_height">50dp</dimen>
</resources>
- xlarge/dimens.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="button_width">200dp</dimen>
<dimen name="button_height">100dp</dimen>
</resources>