FILL_PARENT和了maxWidth不起作用 [英] fill_parent and maxWidth doesn't work

查看:257
本文介绍了FILL_PARENT和了maxWidth不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FILL_PARENT和了maxWidth不能正常工作!我收到这样的: http://bit.ly/VReGBe 它忽略maxWith。 我无法找到任何一个例子maxWith如何工作的。 请大家帮帮忙。

我的code:

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =match_parent
    机器人:方向=垂直>

    <的LinearLayout
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =match_parent
        机器人:方向=垂直>

        <的EditText
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:=了maxWidth50dip/>
    < / LinearLayout中>

< / LinearLayout中>
 

解决方案

属性了maxWidth 对的宽度没有影响 match_parent (或pcated去$ P $ FILL_PARENT ),它们是相互排斥的。你需要使用 WRAP_CONTENT

同时那只有一个孩子任何布局大概可以去掉,比如你可以简化您目前的布局:

 < XML版本=1.0编码=UTF-8&GT?;
< EditText上的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:=了maxWidth50dip/>
 

fill_parent and maxWidth doesn't works properly! I receive this: http://bit.ly/VReGBe It is ignoring maxWith. I cannot find no one example how maxWith working. Please help.

my code:

<?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="match_parent"
    android:orientation="vertical" >

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

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:maxWidth="50dip" />
    </LinearLayout>

</LinearLayout>

解决方案

The attribute maxWidth has no effect on a width of match_parent (or the deprecated fill_parent), they are mutually exclusive. You need to use wrap_content.

Also any layout that only has one child can probably be removed, for instance you can simplify you current layout to:

<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:maxWidth="50dip" />

这篇关于FILL_PARENT和了maxWidth不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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