2013-03-15 95 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>