2013-03-05 89 views
0

现在,我的应用程序的主屏幕上有50%的屏幕使用按钮/内容,而最下面的50%只是显示标志。不过,我似乎无法改变它,因此徽标只占据屏幕底部的25%。Android - 获取布局使用75%的屏幕时出现问题

我使用顶部的layout_weight为3,底部为1,但这会导致底部徽标现在占用屏幕区域的95%,并且主区域中的所有内容都不再可见。对外部容器使用weightSum没有奏效,并且都没有将layout_width/height改为fill_parent或wrap_content组合。

我已阅读其他帮助使用layout_weight的线程,并阅读文档,它似乎都很直接,并已在内容领域使用它们没有问题,我不知道为什么这给了我这里的麻烦,任何人都可以帮帮我?

这里是我的代码:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:gravity="center_vertical" 
android:textColor="#000000" 
android:background="#faff67" 
> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:background="@drawable/backing" 
    android:paddingTop="5dp" 
    android:paddingRight="3dp" 
    android:paddingLeft="3dp" 
    android:paddingBottom="3dp" 
    android:layout_margin="3dp" 
android:layout_weight="3" 
    > 

    <!-- Main content area stuff --> 


</LinearLayout> 
<LinearLayout 
android:id="@+id/main" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:paddingTop="0dp" 
android:layout_weight="1" 
    > 
<ImageView android:scaleType="fitCenter" 
      android:contentDescription="Logo" 
      android:src="@drawable/logo" 
      android:id="@+id/front_logo" 
      android:padding="1sp" 
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent"></ImageView> 
</LinearLayout> 
</LinearLayout> 
+0

检查了这一点http://stackoverflow.com/a/16518557/1939564 – 2013-12-05 11:48:03

回答

2

使用android:layout_weight,你应该设置为android:layout_height="0dp"增重部件。否则,在某些情况下,版面高度会超过权重。

当然,这是垂直布局。对于卧式,请使用android:layout_width="0dp"

0

您正在使用重量属性不正确。无论何时设置weight参数,都应将相应的宽度或高度设置为0dp。因此,请将您分配权重的布局的高度更改为0dp。

android:layout_height="0dp" 
0

使用此

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#faff67" 
android:orientation="vertical" 
android:textColor="#000000" > 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:background="#123123" 
    android:gravity="center" 
    android:orientation="vertical" > 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/main" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="3" > 

    <ImageView 
     android:id="@+id/front_logo" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:contentDescription="Logo" 
     android:padding="1sp" 
     android:scaleType="fitCenter" 
     android:src="@drawable/logo" > 
    </ImageView> 
</LinearLayout> 

</LinearLayout>