In this article we will radio group orientation , radio button layout direction
- By Default RadioGroup Will be in Vertical Orientaion , If you want to change use android:orientation="horizontal" attritube of RadioGroup .
- By Default RadioButton Will be in Left to Right Direction , If you want to change use android:layoutDirection="rtl" attritube of RadioButton .
Note : When your application has arabic local , then there will be a need of right to left layout direction.
XML Layout | Preview |
---|---|
1. RadioButton Vertical Orientaion (Left To Right LayoutDirection) <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 1" android:textSize="16sp"/> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 2" android:textSize="16sp"/> </RadioGroup> |
|
2. RadioButton Vertical Orientaion (Right To Left LayoutDirection) <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 1" android:layoutDirection="rtl" android:textSize="16sp"/> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 2" android:layoutDirection="rtl" android:textSize="16sp"/> </RadioGroup> |
|
3. RadioButton Horizontal Orientaion (Left To Right LayoutDirection) <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 1" android:textSize="16sp"/> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 2" android:textSize="16sp"/> </RadioGroup> |
|
4. RadioButton Horizontal Orientaion (Right To Left LayoutDirection) <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 1" android:layoutDirection="rtl" android:textSize="16sp"/> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 2" android:layoutDirection="rtl" android:textSize="16sp"/> </RadioGroup> |
No comments:
Post a Comment