Reputation: 13
Im trying to put scrolview without success.. this the error i get: Rendering Problems Exception raised during rendering: ScrollView can host only one direct child (Details) im getting this when i replace the linearLayout to ScrolView heny suggetion?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.example.jbt.mymovie.Edit_MovieScreen"
android:id="@+id/editScreenLinearLayout">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:id="@+id/linearLayout">
<TextView
android:layout_width="0sp"
android:layout_height="wrap_content"
android:text="Movie Name"
android:id="@+id/SubjectTV"
android:textSize="24dp"
android:layout_weight="50" />
<EditText
android:layout_width="0sp"
android:layout_height="wrap_content"
android:id="@+id/movieNameImplement"
android:layout_weight="50"
android:text="@string/MovieNameEditText" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Summery :"
android:id="@+id/SummeryTV"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/SummeryImplement"
android:layout_weight="10064.12"
android:text="@string/SummeryImplement" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:id="@+id/linearLayout2">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/URLtextView"
android:id="@+id/URLtv"
android:textSize="18dp"
android:layout_weight="15" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/UrlImplement"
android:layout_weight="60"
android:text="@string/UrlImplement" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/ShowButton"
android:id="@+id/ShowB"
android:onClick="showButton"
android:layout_weight="20" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="press show to get photo"
android:id="@+id/ErrortextView"
android:layout_gravity="center_horizontal" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@mipmap/ic_launcher"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/OKbutton"
android:id="@+id/OKbutton"
android:layout_gravity="center|bottom"
android:onClick="onClickaddMovie"
android:layout_weight="50" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/CancelButton"
android:onClick="cancelButton"
android:id="@+id/CancelButton"
android:layout_marginLeft="28dp"
android:layout_marginStart="28dp"
android:layout_gravity="center|bottom"
android:layout_weight="50" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Views: 537
Reputation: 423
The error is pretty much what it says - the ScrollView only can have one child. You have a TextView and a EditText in it. Try to wrap those two in a LinearLayout and the LinearLayout in a ScrollView.
A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll http://developer.android.com/reference/android/widget/ScrollView.html
Upvotes: 2
Reputation: 2885
The Error is saying that you can have only one direct child in the scroll view but you are adding more then one view inside a scrollview what you can do is
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
**<!-- Add here which you want -->**
</LinearLayout>
</ScrollView>
so your code will be like
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/editScreenLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.jbt.mymovie.Edit_MovieScreen">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<TextView
android:id="@+id/SubjectTV"
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:text="Movie Name"
android:textSize="24dp" />
<EditText
android:id="@+id/movieNameImplement"
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:text="@string/MovieNameEditText" />
</LinearLayout>
<TextView
android:id="@+id/SummeryTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Summery :"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<EditText
android:id="@+id/SummeryImplement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10064.12"
android:text="@string/SummeryImplement" />
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<TextView
android:id="@+id/URLtv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="15"
android:text="@string/URLtextView"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18dp" />
<EditText
android:id="@+id/UrlImplement"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="60"
android:text="@string/UrlImplement" />
<Button
android:id="@+id/ShowB"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:onClick="showButton"
android:text="@string/ShowButton" />
</LinearLayout>
<TextView
android:id="@+id/ErrortextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="press show to get photo"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<Button
android:id="@+id/OKbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"
android:layout_weight="50"
android:onClick="onClickaddMovie"
android:text="@string/OKbutton" />
<Button
android:id="@+id/CancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"
android:layout_marginLeft="28dp"
android:layout_marginStart="28dp"
android:layout_weight="50"
android:onClick="cancelButton"
android:text="@string/CancelButton" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Upvotes: 1
Reputation: 1344
You can not put two saperate view inside a scroll view, you need to add all view inside one view. Use this code, or similar one.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.jbt.mymovie.Edit_MovieScreen">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/editScreenLinearLayout">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:id="@+id/linearLayout">
<TextView
android:layout_width="0sp"
android:layout_height="wrap_content"
android:text="Movie Name"
android:id="@+id/SubjectTV"
android:textSize="24dp"
android:layout_weight="50" />
<EditText
android:layout_width="0sp"
android:layout_height="wrap_content"
android:id="@+id/movieNameImplement"
android:layout_weight="50"
android:text="@string/MovieNameEditText" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Summery :"
android:id="@+id/SummeryTV"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/SummeryImplement"
android:layout_weight="10064.12"
android:text="@string/SummeryImplement" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:id="@+id/linearLayout2">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/URLtextView"
android:id="@+id/URLtv"
android:textSize="18dp"
android:layout_weight="15" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/UrlImplement"
android:layout_weight="60"
android:text="@string/UrlImplement" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/ShowButton"
android:id="@+id/ShowB"
android:onClick="showButton"
android:layout_weight="20" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="press show to get photo"
android:id="@+id/ErrortextView"
android:layout_gravity="center_horizontal" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@mipmap/ic_launcher"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/OKbutton"
android:id="@+id/OKbutton"
android:layout_gravity="center|bottom"
android:onClick="onClickaddMovie"
android:layout_weight="50" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/CancelButton"
android:onClick="cancelButton"
android:id="@+id/CancelButton"
android:layout_marginLeft="28dp"
android:layout_marginStart="28dp"
android:layout_gravity="center|bottom"
android:layout_weight="50" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Upvotes: 0