2011-08-03 161 views
1

使用相对布局上的Android游戏的菜单,但是,推出不同尺寸的仿真器和布局不能扩展都很好,即使我使用浸。在中等屏幕,它工作正常,但是小屏幕削减一半的底部按钮关闭,大屏幕进一步scrunches所有的按钮在屏幕,任何想法?Android的布局调整大小

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/menubackground" 
> 
<Button 
android:text="High Scores" 
android:layout_height="wrap_content" 
android:layout_width="200dp" 
android:id="@+id/HighScore" 
android:layout_below="@+id/NewGame" 
android:layout_centerHorizontal="true" 
android:layout_marginTop="20dp" 
android:textStyle="bold" 
></Button> 
<Button 
android:text="Instructions" 
android:layout_height="wrap_content" 
android:layout_width="200dp" 
android:id="@+id/Instructions" 
android:layout_below="@+id/HighScore" 
android:layout_centerHorizontal="true" 
android:layout_marginTop="20dp" 
android:textStyle="bold" 
></Button> 
<Button 
android:text="Exit" 
android:layout_height="wrap_content" 
android:layout_width="200dp" 
android:id="@+id/Exit" 
android:layout_below="@+id/Instructions" 
android:layout_centerHorizontal="true" 
android:layout_marginTop="20dp" 
android:textStyle="bold" 
> 

</Button> 
<Button android:layout_height="wrap_content" 
android:textStyle="bold" 
android:id="@+id/NewGame" 
android:text="New Game" 
android:layout_width="200dp" 
android:layout_alignParentTop="true" 
android:layout_alignLeft="@+id/HighScore" 
android:layout_marginTop="191dp"></Button> 

</RelativeLayout> 
+0

我能问,这是什么,这不是缩放吧?宽度或高度?或者更具体地说,哪些视图正在“切断”或不能正确显示? – Brian

+0

最后一个按钮(出口)在较小的屏幕上被切断。宽度很好,高度是问题。 –

回答

0

也许RelativeLayout是不是在这里的最佳选择。我会做的是在垂直方向上使用LinearLayout。使用weight你可以让这个允许元素被均匀地隔开,无论屏幕大小。也许,尝试这样的事情:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 
<Button android:id="@+id/new_game" 
    android:layout_width="200dp" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:text="feasdf" 
/> 
<Button android:id="@+id/instructions" 
    android:layout_width="200dp" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:text="feasdf" 
/> 
<Button android:id="@+id/exit_game" 
    android:layout_width="200dp" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:text="feasdf" 
/> 

让我知道如果你有任何其他问题!

+0

谢谢AeroDroid,这正是我一直在后! –

+0

没问题,只要记住接受这个答案,如果你发现它有帮助。只需点击这个问题旁边的灰色检查。 :) – Brian

0

RelativeLayoutScrollView 。这将以较小的屏幕尺寸显示正在切断的部分。它不会影响可以在屏幕上查看所有内容的较大屏幕尺寸。

+0

有没有做它不涉及不必滚动? –

+0

你可以使按钮较小 –