samedi 30 avril 2016

Android CheckBox text moves up when checked

I create a simple form inside an activity which user can select some items by checking the corresponding CheckBoxes and everythings act normal in runtime. After adding this layout into a TabHost by including the layout, checkbox text goes up when touched (i.e. just like setting gravity to up). I have tried to correct this issue by overriding checkbox text gravity in onCheckedChangeListener but it seems that the problem is not related to gravity.

this is how I have included the layout to tabhost:

<TabHost
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/tabHost"
    android:layout_below="@id/my_toolbar" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"></TabWidget>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/tab1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <include
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    layout="@layout/activity_main"
                    android:id="@+id/tab1Layout" />
            </LinearLayout>

and this is activity main layout:

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/answer0TL"
    android:layout_below="@id/info0TextView" >

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/one0TR">

        <CheckBox
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="Food"
            android:id="@+id/foodCheckBox"
            android:layout_weight="1" />

        <CheckBox
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="Dinning out / Restaurants"
            android:id="@+id/restaurantsCheckBox"
            android:layout_weight="1" />
    </TableRow>

What is wrong with this code?




Aucun commentaire:

Enregistrer un commentaire