2013-10-02 72 views
0

我想做3個大柱子來分隔3個活動。但我不確定如何拆分第二列,我想在其中放置地圖。任何幫助表示讚賞!謝謝!佈局問題。在使用表格時遇到問題

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <!----- 1 main table to split into 3 columns ------> 
    <TableLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

     <!----- 1 row ------> 
     <TableRow 
       android:id="@+id/tableRow4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       > 
      <[email protected]@@@@@@@@@@@@@@@@@@@@@@@- Column 1 @@@@@@@@@@@@@@@@@@@@@@@@------> 
     <TableLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      > 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" > 

       <Button 
        android:id="@+id/connect_button" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:orientation="horizontal" 
        android:text="Connect" /> 

       <Button 
        android:id="@+id/disconnect_button" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:text="Disconnect" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="207dp" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" > 

       <TextView 
        android:id="@+id/status_button" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:background="#FFFF00" 
        android:gravity="center" 
        android:orientation="horizontal" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" > 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" > 

       <Button 
        android:id="@+id/s1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:orientation="horizontal" 
        android:text="S1" /> 

       <Button 
        android:id="@+id/s2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:orientation="horizontal" 
        android:text="S2" /> 

       <ImageButton 
        android:id="@+id/configure" 
        android:layout_width="81dp" 
        android:layout_height="wrap_content" 
        android:onClick="openConfigurations" 
        android:src="@android:drawable/ic_menu_manage" /> 
      </LinearLayout> 

      <TableLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

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

        <Gallery 
         android:id="@+id/gallery2" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" /> 

        <ImageButton 
         android:id="@+id/up" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_column="2" 
         android:src="@drawable/up" /> 
       </TableRow> 

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

        <ImageButton 
         android:id="@+id/left" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_column="1" 
         android:src="@drawable/left" /> 

        <ToggleButton 
         android:id="@+id/toggle" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_column="2" 
         android:layout_gravity="center" 
         android:background="@drawable/check" 
         android:textOff="" 
         android:textOn="" /> 

        <ImageButton 
         android:id="@+id/right" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_column="3" 
         android:src="@drawable/right" /> 
       </TableRow> 

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

        <ImageButton 
         android:id="@+id/down" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_column="2" 
         android:src="@drawable/down" /> 
       </TableRow> 
      </TableLayout> 
    </TableLayout> 


        <[email protected]@@@@@@@@@@@@@@@- Column 2 @@@@@@@@@@@@@@@@@------> 
     <RelativeLayout 
      android:id="@+id/gridView1" 
      android:layout_width="match_parent" 
      android:layout_height="500dp" 
      android:layout_marginTop="27dp" 
      android:layout_column="0" 
      android:layout_gravity="center" 
      android:layout_row="9" 
      android:background="#FFFFAA" > 

     <com.example.project.image_map 
      android:id="@+id/mapView1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" /> 

    </RelativeLayout> 

       <[email protected]@@@@@@@@@@@@@@@- Column 3 @@@@@@@@@@@@@@@@@------> 
     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" 
      android:layout_column="3"/> 

    </TableRow> 
    </TableLayout> 



</LinearLayout> 

我不知道,因爲我試圖把「機器人:layout_column =」 2" 的相對佈局,有一個錯誤,我應該如何確定是哪個活動,其中列這是?不像圖像或按鈕,我只是簡單地添加在layout_column中。

+0

究竟是什麼意思由3個大列分隔3個活動。 –

回答

1

在RelativeLayout中,您的UI組件位置是相對於其他UI組件和父容器的,不能在RelativeLayout中使用android:layout_column。活動的任何列,只要你在你的java活動類中添加一個引用即可。

0

我不確定什麼喲你在尋找。你可能想要做的事情不同。

首先,這裏是你的佈局看起來像在景觀orinetation: current layout/landscape

接下來的問題是,什麼是錯的呢?你想怎麼樣?我可以承擔一些事情,但需要更多的指導。

  • 在縱向方向上沒有足夠的空間來顯示如此複雜的屏幕。您可以在清單中設置此活動只應在橫向模式下顯示,不應改變方向,無論用戶做什麼。在清單中設置此方法:<activity android:name="+yourActivityClass+" android:screenOrientation="landscape"></activity>
  • 也許您想將三個區域拆分爲三個不同的屏幕,並可以在它們之間切換,例如通過從左至右擦拭。在這種情況下,你最好使用Fragments。在Eclipse中,當您創建一個新的Activity時,它會詢問您需要的導航類型並創建一個框架。