Android使用线性布局maxWidth,不适用于fill_parent [英] Android using Linear layout maxWidth, not work with fill_parent
本文介绍了Android使用线性布局maxWidth,不适用于fill_parent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用fill_parent
时,maxWidth
无效.
<?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 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>
推荐答案
属性maxWidth
对match_parent
(或已弃用的fill_parent
)的宽度没有影响,它们是互斥的.您需要使用wrap_content
.
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"/>
这篇关于Android使用线性布局maxWidth,不适用于fill_parent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文