1

I have an activity which contains a table layout and below it I have some buttons, I then implemented a sort of navigation bar using radio group and radio buttons. What I want to do is add a horizontal scroll view to this radio group, however when I try to add it the navigation bar just changes position to the top of the activity to collapse with the table layout and I need this navigation bar to stick to the bottom of the activity. Any help would be much appreciated. Thanks in advance.

Here's my xml code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bckgroundchinese"
    android:id="@+id/bottom_layout" >


    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbarFadeDuration="0"
        android:scrollbarSize="12dip" >

        <HorizontalScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:background="#3b3b3b" >

            <TableLayout
                android:id="@+id/myTableLayout"
                android:layout_width="match_parent"
                android:layout_height="276dp"
                android:background="@drawable/bckgroundchinese" >

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="NO PATIENTS" />
            </TableLayout>
        </HorizontalScrollView>
    </ScrollView>


    <Button
        android:id="@+id/patient"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/radioGroup1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:background="@drawable/buttonchinese"
        android:text="Add Patient" />

    <Button
        android:id="@+id/signtOutDr"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/patient"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:background="@drawable/buttonchinese"
        android:text="sign out" />


     <Button
        android:id="@+id/info"
        android:layout_width="450dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_above="@+id/alerts"
        android:background="@drawable/buttonchinese"
        android:text="Edit My Information" />


    <Button
        android:id="@+id/alerts"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/signtOutDr"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:background="@drawable/buttonchinese"
        android:text="View Alerts" />
    <!-- 
     <HorizontalScrollView
        android:id="@+id/scrollView2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbarFadeDuration="0"
        android:scrollbarSize="5dip" >
     -->


     <RadioGroup
         android:id="@+id/radioGroup1"
         android:layout_width="fill_parent"
         android:layout_height="71dp"
         android:layout_alignParentBottom="true"
         android:layout_alignParentLeft="true"
         android:background="@drawable/bckgroundchinese"
         android:orientation="horizontal" >

         <RadioButton
             android:id="@+id/btnAll"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:drawableTop="@drawable/navbar_allselector"
             android:gravity="bottom|center_horizontal"
             android:text="My Patients" />

         <RadioButton
             android:id="@+id/btnPicture"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:drawableTop="@drawable/doctoricon"
             android:text="View Assistants" />

         <RadioButton
             android:id="@+id/btnVideo"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:drawableTop="@drawable/records"
             android:text="Add Assistants" />

         <RadioButton
             android:id="@+id/btnFile"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:drawableTop="@drawable/phonebook_"
             android:text="Add Patient" />

         <RadioButton
             android:id="@+id/btnEditInfo"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:drawableTop="@drawable/phonebook_"
             android:text="Edit My Info" />
     </RadioGroup>
     <!-- </HorizontalScrollView> -->

</RelativeLayout>
4

2 回答 2

2

Salma 我已经解决了您的问题,但删除了一些背景图像,因为它在我的系统中不存在,因此请使用以下代码并添加这些背景图像。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:id="@+id/bottom_layout" >

        <HorizontalScrollView
            android:id="@+id/mytabview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:background="#3b3b3b" >

            <TableLayout
                android:id="@+id/myTableLayout"
                android:layout_width="match_parent"
                android:layout_height="276dp"


                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="NO PATIENTS" />
            </TableLayout>
        </HorizontalScrollView>
    <!-- 
     <HorizontalScrollView
        android:id="@+id/scrollView2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbarFadeDuration="0"
        android:scrollbarSize="5dip" >
     -->
     <!-- </HorizontalScrollView> -->

     <LinearLayout
         android:id="@+id/nav"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_below="@id/mytabview" >

         <Button
             android:id="@+id/patient"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:background="@drawable/buttonchinese"
             android:text="Add Patient" />

         <Button
             android:id="@+id/signtOutDr"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:background="@drawable/buttonchinese"
             android:text="sign out" />

         <Button
             android:id="@+id/info"
             android:layout_width="450dp"
             android:layout_height="wrap_content"
             android:background="@drawable/buttonchinese"
             android:text="Edit My Information" />

         <Button
             android:id="@+id/alerts"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:background="@drawable/buttonchinese"
             android:text="View Alerts" />
     </LinearLayout>

     <RadioGroup
         android:id="@+id/radioGroup1"
         android:layout_width="fill_parent"
         android:layout_height="71dp"
         android:layout_alignParentBottom="true"
         android:background="@drawable/bckgroundchinese"
         android:orientation="horizontal" >

         <RadioButton
             android:id="@+id/btnAll"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:drawableTop="@drawable/navbar_allselector"
             android:gravity="bottom|center_horizontal"
             android:text="My Patients" />

         <RadioButton
             android:id="@+id/btnPicture"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:drawableTop="@drawable/doctoricon"
             android:text="View Assistants" />

         <RadioButton
             android:id="@+id/btnVideo"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:drawableTop="@drawable/records"
             android:text="Add Assistants" />

         <RadioButton
             android:id="@+id/btnFile"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:drawableTop="@drawable/phonebook_"
             android:text="Add Patient" />

         <RadioButton
             android:id="@+id/btnEditInfo"
             style="@style/navbar_button"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:drawableTop="@drawable/phonebook_"
             android:text="Edit My Info" />
     </RadioGroup>

</RelativeLayout>
于 2013-05-04T17:38:20.637 回答
1

您需要移动这些属性:

 android:layout_alignParentBottom="true"
 android:layout_alignParentLeft="true"

RadioGroupHorizontalScrollView,像这样:

 <HorizontalScrollView
    android:id="@+id/scrollView2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:scrollbarFadeDuration="0"
    android:scrollbarSize="5dip" >

 <RadioGroup
     android:id="@+id/radioGroup1"
     android:layout_width="fill_parent"
     android:layout_height="71dp"
     android:background="@drawable/bckgroundchinese"
     android:orientation="horizontal" >

     <RadioButton
         android:id="@+id/btnAll"
         style="@style/navbar_button"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:drawableTop="@drawable/navbar_allselector"
         android:gravity="bottom|center_horizontal"
         android:text="My Patients" />

     <RadioButton
         android:id="@+id/btnPicture"
         style="@style/navbar_button"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:layout_marginLeft="5dp"
         android:drawableTop="@drawable/doctoricon"
         android:text="View Assistants" />

     <RadioButton
         android:id="@+id/btnVideo"
         style="@style/navbar_button"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:layout_marginLeft="5dp"
         android:drawableTop="@drawable/records"
         android:text="Add Assistants" />

     <RadioButton
         android:id="@+id/btnFile"
         style="@style/navbar_button"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:layout_marginLeft="5dp"
         android:drawableTop="@drawable/phonebook_"
         android:text="Add Patient" />

     <RadioButton
         android:id="@+id/btnEditInfo"
         style="@style/navbar_button"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:layout_marginLeft="5dp"
         android:drawableTop="@drawable/phonebook_"
         android:text="Edit My Info" />
 </RadioGroup>

于 2013-05-04T17:10:47.220 回答