Question

I have trouble adding scroll view to my layout. What shall I do?

error says : Multiple annotations found at this line: - This ScrollView view is useless (no children, no background, no id, no style) - The element type "Scrollview" must be terminated by the matching end-tag "".

<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: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=".MainActivity" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:orientation="vertical" >
</LinearLayout>






<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="کد اطلاعات عمومی گوشی" />

<Button
    android:id="@+id/button2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button1"
    android:layout_centerHorizontal="true"
    android:text="کد فکتوری ریست گوشی بدون از بین بردن اپلیکیشن ها" />

<Button
    android:id="@+id/button3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button2"
    android:layout_centerHorizontal="true"
    android:text="کد فکتوری ریست کلی" />

<Button
    android:id="@+id/button4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button3"
    android:layout_centerHorizontal="true"
    android:text="اطلاعات دوربین" />

<Button
    android:id="@+id/button5"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button4"
    android:layout_centerHorizontal="true"
    android:text="تغییر عملکرد دکمه power/end call" />

<Button
    android:id="@+id/button6"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button5"
    android:layout_centerHorizontal="true"
    android:text="پشتیبان گیری از فایل ها(عکس ها ، یادداشت ها و...)" />

<Button
    android:id="@+id/button7"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button6"
    android:layout_centerHorizontal="true"
    android:text="انجام تست و تنظیم بعضی از تنطیمات گوشی" />

<Button
    android:id="@+id/button8"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button7"
    android:layout_centerHorizontal="true"
    android:text="کد تست های سخت افزاری" />

<Button
    android:id="@+id/button9"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button8"
    android:layout_centerHorizontal="true"
    android:text="Button" />

<Button
    android:id="@+id/button10"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button9"
    android:layout_centerHorizontal="true"
    android:text="Button" />

</ScrollView>
</Scrollview>
</LinearLayout>
</LinearLayout>

pls correct the code. Thanks for advance

Was it helpful?

Solution 3

New layout:

<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: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=".MainActivity"
    >
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:orientation="vertical"
    >
        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:text="?? ??????? ????? ????"
        />
        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button1"
            android:layout_centerHorizontal="true"
            android:text="?? ?????? ???? ???? ???? ?? ??? ???? ???????? ??"
        />
        <Button
            android:id="@+id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button2"
            android:layout_centerHorizontal="true"
            android:text="?? ?????? ???? ???"
        />
        <Button
            android:id="@+id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button3"
            android:layout_centerHorizontal="true"
            android:text="??????? ??????"
        />
        <Button
            android:id="@+id/button5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button4"
            android:layout_centerHorizontal="true"
            android:text="????? ?????? ???? power/end call"
        />
        <Button
            android:id="@+id/button6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button5"
            android:layout_centerHorizontal="true"
            android:text="??????? ???? ?? ???? ??(??? ?? ? ??????? ?? ?...)"
        />
        <Button
            android:id="@+id/button7"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button6"
            android:layout_centerHorizontal="true"
            android:text="????? ??? ? ????? ???? ?? ??????? ????"
        />
        <Button
            android:id="@+id/button8"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button7"
            android:layout_centerHorizontal="true"
            android:text="?? ??? ??? ??? ??????"
        />
        <Button
            android:id="@+id/button9"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button8"
            android:layout_centerHorizontal="true"
            android:text="Button"
        />
        <Button
            android:id="@+id/button10"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button9"
            android:layout_centerHorizontal="true"
            android:text="Button"
        />
    </LinearLayout>
</Scrollview>

OTHER TIPS

ScrollView can only take one child view. What you need to do is put your views like all the buttons in a LinearLayout or RelativeLayout view and then add a scrollView.

A ScrollView can only contain a single child, hence you need to have something like this:

<ScrollView>
    <LinearLayout>
        <Button />
        <Button />
        <Button />
        <Button />
    </LinearLayout>
</ScrollView>

You also have a bunch of close tags at the end which you should get rid of:

</Scrollview>
</LinearLayout>
</LinearLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top