如何设置这种布局适合于任何屏幕的高度? [英] How to set this Layout that fit to Any Screen height?

查看:175
本文介绍了如何设置这种布局适合于任何屏幕的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于我的应用程序的一些布局问题。 这是我的应用程序布局:

I have Some layout Problem regarding my Application. This is My Application Layout:

<?xml version="1.0" encoding="utf-8"?>

<ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:src="@drawable/tax_calculator_logo"/>
<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent"
    android:orientation="vertical" android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp" android:layout_gravity="center" 
    android:layout_marginTop="10dp" android:layout_marginBottom="10dp">

    <Button android:id="@+id/contactUs" android:layout_height="wrap_content"
        android:layout_width="fill_parent" android:text="Contact Us"
        android:textSize="20dp"/>
    <Button android:id="@+id/contactUs" android:layout_height="wrap_content"
        android:layout_width="fill_parent" android:text="Contact Us"
        android:textSize="20dp"/>   
    <Button android:id="@+id/contactUs" android:layout_height="wrap_content"
        android:layout_width="fill_parent" android:text="Contact Us"
        android:textSize="20dp"/>   
    <Button android:id="@+id/contactUs" android:layout_height="wrap_content"
        android:layout_width="fill_parent" android:text="Contact Us"
        android:textSize="20dp"/>   
</LinearLayout>

在这里,我要设置这一切按钮来完成可与任何设备的屏幕的高度。 是的,我可以显示所有的按钮。但我想他们都将有它们之间的空间方程组的,他们必须符合完整的屏幕高度。 那么,我应该做的是??

Here, I want to set this all button to be complete fit with the height of the Screen of any device. Yes i can show all the Button. but i want them all to be have equat space between them and they must be fit complete to the Screen height. So what should i have to do for that ??

编辑:

还有就是,我tax_calculator_logo是600x239的分辨率,我已经设置ImageView的高度WRAP_CONTENT和宽度与FILL_PARENT那么为什么图像从底部和顶部??? croping

And there is, My tax_calculator_logo is of 600x239 resolution and i have set the ImageView height as wrap_content and width with fill_parent then why the Image is croping from bottom and top ???

推荐答案

给予相等的权重,以您的每一个按钮,就会自动共享的高度。

Give equal weight to each of your buttons, they will share height automatically.

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="10dp"
    android:orientation="vertical" >

    <Button
        android:id="@+id/contactUs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Contact Us"
        android:textSize="20dp" />

    <Button
        android:id="@+id/contactUs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Contact Us"
        android:textSize="20dp" />

    <Button
        android:id="@+id/contactUs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Contact Us"
        android:textSize="20dp" />

    <Button
        android:id="@+id/contactUs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Contact Us"
        android:textSize="20dp" />

</LinearLayout>

这篇关于如何设置这种布局适合于任何屏幕的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆