简体   繁体   中英

webview in layout with 4 textviews in top

I do not have much experience with screen layouts xml. I would like to show my screen like this: http://www.consulta-rapida.com/result.png

PS: I would add textvies label3 and Label4 (in red). they are in the figure, but are not in the xml, because I could not aligning them.

Would help to fit these two textviews in my layout below:

  <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:theme="@android:style/Theme.Dialog"
     android:layout_height="fill_parent" >

    <WebView
        android:id="@+id/id_web_view_browser"
        android:layout_above="@+id/id_web_view_bar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

    <RelativeLayout
        android:id="@+id/id_web_view_bar"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:background="#ffffff"
        android:orientation="vertical" >
        <Button
            android:id="@+id/btnCancelar"
            android:background="@drawable/btn_red"
            android:layout_width="fill_parent"
            android:layout_centerHorizontal="true"
            android:layout_height="wrap_content"
            android:text="     Cancelar Corrida      "
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:textSize="20sp" />

    </RelativeLayout>

<RelativeLayout
            android:id="@+id/relativeLayout1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="top">
            <TextView 
                android:id="@+id/txtLabel1"
                android:layout_alignParentLeft="true"
                android:layout_height="wrap_content"
                android:background="#ffffff"
                android:maxLines="1"
                android:layout_width="wrap_content"
                android:text="Label1: Sample1">
            </TextView>
            <TextView
                android:id="@+id/txtLabel2"
                android:layout_alignParentRight="true"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:background="#ffffff"
                android:text="Label2: Sample2">
            </TextView>

</RelativeLayout>

</RelativeLayout>
    <?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:theme="@android:style/Theme.Dialog" >

    <WebView
        android:id="@+id/id_web_view_browser"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/id_web_view_bar"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

        <RelativeLayout
            android:id="@+id/id_web_view_bar"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:layout_alignParentBottom="true"
            android:background="#ffffff"
            android:orientation="vertical" >

            <Button
                android:id="@+id/btnCancelar"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:background="@drawable/btn_red"
                android:text=" Cancelar Corrida      "
                android:textSize="20sp" />
        </RelativeLayout>

        <TableLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginTop="16dp" >

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/txtLabel1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:background="#ffffff"
                    android:maxLines="1"
                    android:text="Label1: Sample1" >
                </TextView>

                <TextView
                    android:id="@+id/txtLabel2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="115dp"
                    android:layout_marginRight="5dp"
                    android:background="#ffffff"
                    android:text="Label2: Sample2" >
                </TextView>
            </TableRow>

            <TableRow
                android:id="@+id/tableRow2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp" >

                <TextView
                    android:id="@+id/txtLabel3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:background="#ffffff"
                    android:maxLines="1"
                    android:text="Label1: Sample1" >
                </TextView>

                <TextView
                    android:id="@+id/txtLabel4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="115dp"
                    android:layout_marginRight="5dp"
                    android:background="#ffffff"
                    android:text="Label2: Sample2" >
                </TextView>
            </TableRow>
        </TableLayout>

    </RelativeLayout>

put them in android:id="@+id/relativeLayout1" relative layout and use layout_below . should work pretty straight forward

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM