什么是0dip layout_height或layouth_width的把戏? [英] What is the trick with 0dip layout_height or layouth_width?

查看:167
本文介绍了什么是0dip layout_height或layouth_width的把戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是,为什么有人要他们认为是0dip高度? 我见过很多次,一定是有什么把戏,但我不明白这一点。

I mean why anybody want they view to be 0dip height ? I have seen this many times, there must be some kind of trick, but I do not get it.

        <TextView android:gravity="top" android:textColor="#FFFF0000"
            android:textSize="20dip" android:text="TextView"
            android:layout_height="0dip" android:layout_width="fill_parent"
            android:id="@+id/contactName"></TextView>

为什么他们没有如WRAP_CONTENT使用?他们怎么想达到什么目的?

Why they don't use for example wrap_content ? what do they want to achieve ?

推荐答案

这是通常具有的LinearLayout里面很多观点时使用,并且已经设置的android:layout_weight =1,以这两种观点采取平等的空间。例如:

This is usually used when having many views inside a linearlayout and have set android:layout_weight="1" in order both views to take equal space. for example:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="TextView" />

</LinearLayout>

在这种情况下,显示将需要多达高度,因为所有的其它视图。

In that case, the view will take as much height as all other views.

这篇关于什么是0dip layout_height或layouth_width的把戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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