gpt4 book ai didi

android-layout - 您必须提供 layout_width 属性异常

转载 作者:行者123 更新时间:2023-12-03 12:59:08 25 4
gpt4 key购买 nike

我有一个布局,它在底部的前 2 个按钮上有标题,中间有一些 TextView 和编辑文本。我愿意将这些 EditText 和 Text View 放在 ScrollView 中,以便我可以滚动并且 EditText 不会隐藏在键盘后面。

这是我的 XML 文件,很抱歉它有点冗长,但是请查看此文件并让我知道这有什么问题。我总是得到
java.lang.RuntimeException:二进制 XML 文件第 73 行:您必须提供 layout_width 属性。
我试过很多方法改变宽度和高度,但我总是得到这个错误。

XML文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal">
<!-- Title(Preview) Background and Text-->
<RelativeLayout
android:id="@+id/previewBG"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/title_bg">

<TextView
android:id="@+id/previewTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addDevicesTittle"
android:textSize="24sp"
android:typeface="sans"
android:textColor="#ffffff"
android:layout_centerInParent="true"
>
</TextView>
</RelativeLayout>
<!-- Title(Preview) Background and Text End -->
<!-- Buttons -->
<LinearLayout
android:id="@+id/Buttons"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:layout_alignParentBottom="true"
android:background="@color/COL_BTNBG">

<LinearLayout
android:id="@+id/btnRefresh_part"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dip">


<Button
android:id="@+id/btnSave"
android:layout_width="fill_parent"
android:layout_height="49dip"
android:text="@string/btn_manual_save"
android:textSize="24sp"
android:typeface="sans"
android:textColor="@color/COL_WHITE"
android:layout_weight ="1"
android:background="@+drawable/button_02"

>
</Button>
<Button
android:id="@+id/btnCancel"
android:layout_width="fill_parent"
android:layout_height="49dip"
android:text="@string/btn_manual_cancel"
android:textSize="24sp"
android:typeface="sans"
android:textColor="@color/COL_WHITE"
android:layout_weight ="1"
android:background="@+drawable/button_02"

>
</Button>

</LinearLayout>
</LinearLayout>
<!-- Buttons End -->

<ScrollView
android:id="@+id/scrollView"
android.layout_width="50dip"
android.layout_height="300dip"
android:layout_below="@+id/previewBG"
>

<RelativeLayout
android:id="@+id/Data"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true">

<TextView
android:id="@+id/domain_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/txtDomain"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_alignParentTop = "true"
android:layout_marginTop="10dip"/>

<EditText
android:id="@+id/domain_edit"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:singleLine ="true"
android:autoText="false"
android:hint ="@string/txtDomainExample"
android:capitalize="none"
android:gravity="fill_horizontal"
android:layout_below = "@+id/domain_view"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/ip_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/manual_IP"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_below = "@+id/domain_edit"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="10dip"/>


<EditText
android:id="@+id/ip_edit"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:singleLine ="true"
android:autoText="false"
android:hint ="@string/enter_IP_address"
android:capitalize="none"
android:gravity="fill_horizontal"
android:layout_below = "@+id/ip_view"
android:textAppearance="?android:attr/textAppearanceMedium" />


<TextView
android:id="@+id/user_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/txtUserName"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_below = "@+id/ip_edit"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="10dip"/>

<EditText
android:id="@+id/user_edit"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:hint ="@string/txtUserNameExample"
android:singleLine ="true"
android:autoText="false"
android:capitalize="none"
android:gravity="fill_horizontal"
android:layout_below = "@+id/user_view"
android:textAppearance="?android:attr/textAppearanceMedium" />


<TextView
android:id="@+id/password_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/txtPassword"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_below = "@+id/user_edit"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="10dip"/>

<EditText
android:id="@+id/password_edit"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:hint ="@string/txtPasswordExample"
android:singleLine ="true"
android:autoText="false"
android:capitalize="none"
android:gravity="fill_horizontal"
android:password = "true"
android:layout_below = "@+id/password_view"
android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>
</ScrollView>

</RelativeLayout>

最佳答案

你的 ScrollView 有 android.layout_width 而不是 android:layout_width ...类似的 layout_height

观察点而不是冒号

那可能是你的问题

关于android-layout - 您必须提供 layout_width 属性异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5685794/

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