2013-03-15 37 views
1

我爲應用程序設計了一個屏幕。無法在屏幕方向上顯示完整項目

這裏是我的xml

<LinearLayout 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/bghomescreen" > 

    <TableLayout 
     android:id="@+id/tlmaintable" 
     android:layout_width="match_parent" 
     android:layout_height="304dp" 
     android:layout_marginTop="100dp" 
     android:orientation="vertical"> 

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

     <Button 
     android:id="@+id/btnsearchbylocation" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:background="@drawable/btn_bg_location" /> 

     <Button 
     android:id="@+id/btnsearchbycuisine" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:background="@drawable/btn_bg_cuisine1" /> 


     </TableRow> 

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

     <Button 
     android:id="@+id/btnquickbite" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:background="@drawable/btn_bg_quickbite" /> 

     <Button 
     android:id="@+id/btnadvancesearch" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:background="@drawable/btn_bg_cuisine"/>  
     </TableRow> 


    </TableLayout> 



</LinearLayout> 

當我運行我的應用程序,我可以看到在風景模式下,所有的項目,但是當我將其轉換爲肖像模式我只能看到我的表視圖的第一行。我無法看到其他人。

我使用尺寸爲480x800的屏幕。

有人可以幫助我。

感謝

+1

使用scrollview。 – rajeshwaran 2013-03-15 12:35:45

+0

@rajeshwaran thnx rajesh。你能否爲我提供任何相同的文件。如果你有任何。感謝名單:)。但rajesh我認爲我必須滾動查看其他圖像。不能一次看到所有的圖像?有沒有辦法做到這一點? – Beginner 2013-03-15 12:37:11

+1

@ user2143817您不需要doc滾動視圖,爲LinearLayout設置定向,並且還將滾動視圖 – Pragnani 2013-03-15 12:40:04

回答

0

,最好的辦法是建立在橫向的屏幕獨立佈局..這將解決給你的問題..

0

試加:

android:orientation="vertical" 

中的LinearLayout:

<LinearLayout 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:orientation="vertical" 
android:background="@drawable/bghomescreen" > 
+0

下的線性佈局保留下來,您會意識到此佈局中只有一個項目,對吧? – njzk2 2013-03-15 12:39:56

0

爲風景和肖像創建單獨的佈局。
對於風景,您可以在layout-land文件夾中編寫xml文件,並根據縱向視圖在layout-port文件夾中使用相同名稱垂直編寫相同的xml文件。
佈局將在您更改方向時自動調用。

+0

thnx的建議,但是當我試圖添加布局土地我得到一些錯誤 – Beginner 2013-03-15 13:03:00

0

我不知道爲什麼不工作我也算高度和保證金和所有的,但我也想知道爲什麼它的行爲這樣

但我嘗試在Eclipse中的代碼,發現一個替代試試這個,如果有幫助你

<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:gravity="center"> 

    <TableLayout 
     android:id="@+id/tlmaintable" 
     android:layout_width="match_parent" 
     android:layout_height="304dp" 
     android:orientation="vertical" > 

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

      <Button 
       android:id="@+id/btnsearchbylocation" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" /> 

      <Button 
       android:id="@+id/btnsearchbycuisine" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" /> 
     </TableRow> 

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

      <Button 
       android:id="@+id/btnquickbite" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" /> 

      <Button 
       android:id="@+id/btnadvancesearch" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" /> 
     </TableRow> 
    </TableLayout> 

</RelativeLayout> 
相關問題