gpt4 book ai didi

Android 使用线性布局 maxWidth,不适用于 fill_parent

转载 作者:IT王子 更新时间:2023-10-28 23:29:33 36 4
gpt4 key购买 nike

使用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

另外任何只有一个 child 的布局都可能被删除,例如,您可以将当前布局简化为:

<?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,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13325403/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com