I'm developing an Android 3.1 Tablet application and asking this here because I haven't found any working answer (or example) in my code.
I have the following piece of code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/materialsLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- 0 . Título del fragment -->
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight=".5"
android:gravity="center_horizontal"
android:text="@string/layout_title_quantity"
android:textAppearance="?android:attr/textAppearanceLarge" />
<!-- 1. Texto -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/layout_qty_size_carton"
android:textAppearance="?android:attr/textAppearanceMedium" />
<!-- 2. Texto -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum=".45" >
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".1"
android:gravity="right"
android:text="@string/layout_req_po"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".05"
android:text="@string/layout_qty_carton"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/qtyPerCartonTxt"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".05"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".01"
android:gravity="center"
android:text="@string/layout_slash"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".05"
android:text="@string/layout_cartoon_size"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/cartonSizeTxt"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".05"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".01"
android:gravity="center"
android:text="@string/layout_slash"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".03"
android:text="@string/layout_weight"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/cartonWeightTxt"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".05"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<!-- 3. Titulo tabla -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/layout_actual_finding"
android:textAppearance="?android:attr/textAppearanceMedium" />
<!-- 4. Cabecera tabla -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum=".5" >
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".07"
android:gravity="center"
android:text="@string/layout_cartoon_number"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".07"
android:gravity="center"
android:text="@string/layout_actual_qty"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".07"
android:gravity="center"
android:text="@string/layout_actual_size"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".07"
android:gravity="center"
android:text="@string/layout_actual_weight"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/btnAddNewActPckCtr"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".05"
android:onClick="onAddNewActPckCtrClick"
android:text="@string/btn_add_new" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum=".5" >
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".07"
android:gravity="right"
android:text="@string/layout_result"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/rGroupResQTYOnline"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_weight=".07"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rResQTYOnlineYes"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:text="@string/layout_yes" />
<RadioButton
android:id="@+id/rResQTYOnlineNo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:text="@string/layout_no" />
</RadioGroup>
<RadioGroup
android:id="@+id/rGroupResSzOnline"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".07"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rResSzOnlineYes"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/layout_yes" />
<RadioButton
android:id="@+id/rResSzOnlineNo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/layout_no" />
</RadioGroup>
<RadioGroup
android:id="@+id/rGroupResWgOnline"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".07"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rResWgOnlineYes"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/layout_yes" />
<RadioButton
android:id="@+id/rResWgOnlineNo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/layout_no" />
</RadioGroup>
<Button
android:id="@+id/btnTakeQtyOnlinePhoto"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".07"
android:onClick="onTakePhotoClick"
android:text="@string/btn_take_photo" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="40dip"
android:layout_marginTop="40dip"
android:layout_weight=".1"
android:gravity="left|center_vertical"
android:text="@string/layout_photos"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Gallery
android:id="@+id/quantityOnlineGallery"
android:layout_width="fill_parent"
android:layout_height="200dip" />
</LinearLayout>
</ScrollView>
I'm trying to center radio buttons inside radiogroup but I don't know how to do it.
I have tried this code:
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center|left"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right" />
</RadioGroup>
But it doesn't work.
How can I do it?
It might help to try this: Align your radio group to center
<RadioGroup
android:id="@+id/rGroupResSzOnline"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".07"
android:gravity="center"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rResSzOnlineYes"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Yes" />
<RadioButton
android:id="@+id/rResSzOnlineNo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="No" />
</RadioGroup>