gpt4 book ai didi

android - android中的多子Relativelayout滚动

转载 作者:行者123 更新时间:2023-11-30 00:29:21 25 4
gpt4 key购买 nike

我要尝试在我的布局中创建一个用户信息表单。我有多个 RelativeLayout。它不会向下滚动以填充其他信息。请看我的布局。它应该向下滚动以填充其他 EditText

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/viewBg"
android:orientation="vertical"
tools:context="zesteve.com.myapplication.AddNewBusiness">

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintRight_toRightOf="parent"
app:title="Add New Business" />

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/toolbar">

<RelativeLayout
android:id="@+id/uname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingTop="8dp">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/personal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="3dp"
android:text="Your Business Name *"
android:textColor="@color/black"
android:textSize="12dp" />

<EditText
android:id="@+id/personalname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/personal"
android:backgroundTint="@color/material_grey_300"
android:hint="Your Full Name"
android:maxLines="1"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/black"
android:textColorHint="#ccc"
android:textSize="15dp" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/bname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/uname"
android:layout_marginTop="0dp"
android:background="@color/white">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/business"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Your Business Name *"
android:textColor="@color/black"
android:textSize="12dp" />

<EditText
android:id="@+id/businessname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/business"
android:backgroundTint="@color/material_grey_300"
android:hint="e.g. Pizza Hut"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/black"
android:textColorHint="#ccc"
android:textSize="15dp" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/locat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bname"
android:layout_marginTop="0dp"
android:background="@color/white">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/loc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Location *"
android:textColor="@color/black"
android:textSize="12dp" />

<EditText
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/loc"
android:backgroundTint="@color/material_grey_300"
android:hint="SELECT LOCATION"
android:inputType="none"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="15dp"
android:textColor="@color/black"
android:textColorHint="#ccc"
android:textSize="14dp" />

<ImageView
android:id="@+id/locicon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_below="@+id/loc"
android:layout_marginBottom="10dp"
android:paddingRight="10dp"
android:src="@drawable/rightangle" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/phone_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/locat"
android:layout_marginTop="0dp"
android:background="@color/white">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/phoneno"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Phone Number *"
android:textColor="@color/black"
android:textSize="12dp" />

<EditText
android:id="@+id/contact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phoneno"
android:backgroundTint="@color/material_grey_300"
android:inputType="number"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/black"
android:textColorHint="#ccc"
android:textSize="16dp" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/bcat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phone_no"
android:layout_marginTop="0dp"
android:background="@color/white">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/selectcat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Select Catagory *"
android:textColor="@color/black"
android:textSize="12dp" />

<zesteve.com.myapplication.MultiSelectionSpinner.MultiSelectionSpinner
android:id="@+id/mySpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/selectcat"
android:backgroundTint="@color/material_grey_300"
android:paddingBottom="15dp"
android:paddingTop="5dp"
android:popupBackground="#fff" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/bweb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bcat"
android:layout_marginTop="0dp"
android:background="@color/white">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Your Website Name"
android:textColor="@color/black"
android:textSize="12dp" />

<EditText
android:id="@+id/website"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/web"
android:backgroundTint="@color/material_grey_300"
android:hint="e.g. www.zesteve.com"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/black"
android:textColorHint="#ccc"
android:textSize="15dp" />
</RelativeLayout>

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/ower"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bweb"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:text="ARE YOU THE OWNER/MANAGER"
android:textColor="@color/black" />

<RelativeLayout
android:id="@+id/owners"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ower"
android:layout_marginTop="0dp"
android:background="@color/white">

<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp">

<RadioButton
android:id="@+id/notown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="No, I am not the Manager" />

<RadioButton
android:id="@+id/yesowner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/notown"
android:paddingLeft="10dp"
android:text="Yes, I am the Manager" />
</RadioGroup>
</RelativeLayout>

<RelativeLayout
android:id="@+id/wcon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/owners"
android:visibility="gone">

<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:text="OWNER DETAILS"
android:textColor="@color/black" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:background="@color/white">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/owncont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Your Phone Number"
android:textColor="@color/black"
android:textSize="12dp" />

<EditText
android:id="@+id/ownerphone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/owncont"
android:backgroundTint="@color/material_grey_300"
android:hint="e.g. www.zesteve.com"
android:inputType="number"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/black"
android:textColorHint="#ccc"
android:textSize="15dp" />
</RelativeLayout>
</RelativeLayout>

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/disc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/wcon"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:text="ADDITIONAL INFORMATION"
android:textColor="@color/black" />

<RelativeLayout
android:id="@+id/ainfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/disc"
android:layout_marginTop="0dp"
android:background="@color/white">

<EditText
android:id="@+id/addinfo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="6"
android:maxLines="10"
android:minLines="4"
android:scrollbars="vertical" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>

我尝试了 ScrollView 但它给出了这个错误 -

ScrollView can host only one direct child

最佳答案

我已经更改了您布局中的一些值。但无论如何,这是您的布局应该的样子。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintRight_toRightOf="parent"
app:title="Add New Business" />

<ScrollView
android:layout_width="match_parent"
android:layout_below="@+id/toolbar"
android:layout_height="match_parent">

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout
android:id="@+id/uname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:paddingTop="8dp">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/personal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="3dp"
android:text="Your Business Name *"
android:textColor="@@color/md_divider_black"
android:textSize="12dp" />

<EditText
android:id="@+id/personalname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/personal"
android:backgroundTint="@color/material_grey_300"
android:hint="Your Full Name"
android:maxLines="1"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/md_divider_black"
android:textColorHint="#ccc"
android:textSize="15dp" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/bname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/uname"
android:layout_marginTop="0dp"
android:background="@color/colorWhite">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/business"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Your Business Name *"
android:textColor="@@color/md_divider_black"
android:textSize="12dp" />

<EditText
android:id="@+id/businessname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/business"
android:backgroundTint="@color/material_grey_300"
android:hint="e.g. Pizza Hut"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/md_divider_black"
android:textColorHint="#ccc"
android:textSize="15dp" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/locat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bname"
android:layout_marginTop="0dp"
android:background="@color/colorWhite">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/loc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Location *"
android:textColor="@@color/md_divider_black"
android:textSize="12dp" />

<EditText
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/loc"
android:backgroundTint="@color/material_grey_300"
android:hint="SELECT LOCATION"
android:inputType="none"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="15dp"
android:textColor="@color/md_divider_black"
android:textColorHint="#ccc"
android:textSize="14dp" />

<ImageView
android:id="@+id/locicon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_below="@+id/loc"
android:layout_marginBottom="10dp"
android:paddingRight="10dp"
android:src="@drawable/ic_profile" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/phone_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/locat"
android:layout_marginTop="0dp"
android:background="@color/colorWhite">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/phoneno"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Phone Number *"
android:textColor="@@color/md_divider_black"
android:textSize="12dp" />

<EditText
android:id="@+id/contact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phoneno"
android:backgroundTint="@color/material_grey_300"
android:inputType="number"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/md_divider_black"
android:textColorHint="#ccc"
android:textSize="16dp" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/bcat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phone_no"
android:layout_marginTop="0dp"
android:background="@color/colorWhite">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/selectcat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Select Catagory *"
android:textColor="@@color/md_divider_black"
android:textSize="12dp" />

<zesteve.com.myapplication.MultiSelectionSpinner.MultiSelectionSpinner
android:id="@+id/mySpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/selectcat"
android:backgroundTint="@color/material_grey_300"
android:paddingBottom="15dp"
android:paddingTop="5dp"
android:popupBackground="#fff" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/bweb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bcat"
android:layout_marginTop="0dp"
android:background="@color/colorWhite">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Your Website Name"
android:textColor="@@color/md_divider_black"
android:textSize="12dp" />

<EditText
android:id="@+id/website"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/web"
android:backgroundTint="@color/material_grey_300"
android:hint="e.g. www.zesteve.com"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/md_divider_black"
android:textColorHint="#ccc"
android:textSize="15dp" />
</RelativeLayout>

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/ower"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bweb"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:text="ARE YOU THE OWNER/MANAGER"
android:textColor="@@color/md_divider_black" />

<RelativeLayout
android:id="@+id/owners"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ower"
android:layout_marginTop="0dp"
android:background="@color/colorWhite">

<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp">

<RadioButton
android:id="@+id/notown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="No, I am not the Manager" />

<RadioButton
android:id="@+id/yesowner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/notown"
android:paddingLeft="10dp"
android:text="Yes, I am the Manager" />
</RadioGroup>
</RelativeLayout>

<RelativeLayout
android:id="@+id/wcon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/owners"
android:visibility="gone">

<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:text="OWNER DETAILS"
android:textColor="@@color/md_divider_black" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:background="@color/colorWhite">

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/owncont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="5dp"
android:text="Your Phone Number"
android:textColor="@@color/md_divider_black"
android:textSize="12dp" />

<EditText
android:id="@+id/ownerphone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/owncont"
android:backgroundTint="@color/material_grey_300"
android:hint="e.g. www.zesteve.com"
android:inputType="number"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:textColor="@color/md_divider_black"
android:textColorHint="#ccc"
android:textSize="15dp" />
</RelativeLayout>
</RelativeLayout>

<zesteve.com.myapplication.font.RobotoTextView
android:id="@+id/disc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/wcon"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingTop="8dp"
android:text="ADDITIONAL INFORMATION"
android:textColor="@@color/md_divider_black" />

<RelativeLayout
android:id="@+id/ainfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/disc"
android:layout_marginTop="0dp"
android:background="@color/colorWhite">

<EditText
android:id="@+id/addinfo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="6"
android:maxLines="10"
android:minLines="4"
android:scrollbars="vertical" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>

关于android - android中的多子Relativelayout滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44743881/

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