in the following code why the appearance of the radio button changes when i set
android:layout_width="fill_parent"
and
android:width="fill_parent"
i am talking about the _radio button _ whose id is left
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RadioGroup
android:id="@+id/orientation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5px" >
<RadioButton
android:id="@+id/horizontal"
android:text="horizontal" />
<RadioButton
android:id="@+id/vertical"
android:text="vertical" />
</RadioGroup>
<RadioGroup
android:id="@+id/gravity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5px"
>
<RadioButton
android:id="@+id/left"
android:text="left"
android:layout_width="fill_parent" // I am talking about this line
/>
<RadioButton
android:id="@+id/center"
android:text="center" />
<RadioButton
android:id="@+id/right"
android:text="right" />
</RadioGroup>
layout_width : the width, either an exact value, WRAP_CONTENT , or FILL_PARENT (replaced by MATCH_PARENT in API Level 8) layout_height : the height, either an exact value, WRAP_CONTENT , or FILL_PARENT (replaced by MATCH_PARENT in API Level 8) Parameters.
Conclusion : fill_parent and match_parent are the same, used when we want the height or width of a view to be as big as its parent view, fill_parent being deprecated. wrap_content is used when we want the view to occupy only as much space as required by it.
match_parent and fill_parent are same property, used to define width or height of a view in full screen horizontally or vertically. These properties are used in android xml files like this. android:layout_width="match_parent" android:layout_height="fill_parent"
FillParent/Match parent: Fill parent is the older version, the updated one is the match parent which takes the entire screen. Wrap Content: Wrap content takes the length of the text and wraps its content. Example: “This is a Wrap Text”. The wrap content starts wrapping from “This” and ends at “text”.
android:width is for setting an exact number of pixels.
android:layout_width can be a dimension, as above, or it can be one of fill_parent
, match_parent
, or wrap_content
.
It is an error to use something other than a dimension for android:width
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With