Width and Height Property

In my last article we have added button. You can see the following code of button

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me"
android:id="@+id/b1"
android:layout_below="@+id/txt_data"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="83dp"
android:onClick="btn_click"

		

In this code you can see layout_width property. This property is used to set the width of the given control.

This property has following options:-

Wrap_content :- when you set width as wrap_content then it will take the space according to the content. For example

		android height and width property
		Figure 1
		

According to content the width has been changed.

Fill_parent:- fill_parent will take the width according to the container in which we added button.

		
		layout property
		Figure 2
		

Fill_parent replaced by the match_parent in API Level 8

We can also set it in pixel like 200px etc.. Similarly we can set the value of layout_height.

Email Address

For any query you can send mail at info@techaltum.com