user2348911
user2348911

Reputation:

Android ScrollView doesnt work

This is the problemI'm trying to use scrollview in an app, but it doesn't work, the scroll bar doesn't appear and the buttons overlap, I'm using RelativeLayout to do this, I tried by other ways, but it doesn't work too.

Does someone know what I have to do?

Here is the code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
            <Button
                style="?android:attr/buttonStyleSmall"
                android:layout_width="81dp"
                android:layout_height="61dp"
                android:layout_marginTop="20dp"
                android:layout_marginLeft="20dp"
                android:text="@string/Texto14"
                android:id="@+id/buttonHomePerfilV"
                android:textColor="#ffffff"
                android:background="#333399"
                android:layout_alignParentTop="true"
                android:layout_alignParentStart="true" />

            <Button
                android:layout_width="291dp"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/buttonIDAmizadePerfilV"
                android:layout_marginBottom="70dp"
                android:text="@string/Texto15"
                android:id="@+id/buttonIniciarConversaPerfilV"
                android:textColor="#ffffff"
                android:background="#333399"
                android:layout_above="@+id/buttonIDAmizadePerfilV"
                android:layout_centerHorizontal="true" />
            <Button
                android:layout_width="291dp"
                android:layout_height="wrap_content"
                android:text="@string/Texto16"
                android:id="@+id/buttonIDAmizadePerfilV"
                android:layout_marginBottom="20dp"
                android:textColor="#ffffff"
                android:background="#333399"
                android:layout_alignParentBottom="true"
                android:layout_alignStart="@+id/buttonIniciarConversaPerfilV" />

            <ImageView
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:id="@+id/imageViewPerfilV"
                android:src="@drawable/ic_launcher"
                android:layout_below="@+id/buttonHomePerfilV"
                android:layout_centerHorizontal="true" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/Texto8"
                android:id="@+id/textViewNomePerfilV"
                android:layout_below="@+id/imageViewPerfilV"
                android:layout_alignStart="@+id/buttonHomePerfilV" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/Texto9"
                android:id="@+id/textViewCursoPerfilV"
                android:layout_toEndOf="@+id/buttonHomePerfilV"
                android:layout_centerVertical="true"
                android:layout_alignStart="@+id/textViewNomePerfilV" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/Texto10"
                android:id="@+id/textViewDataPerfilV"
                android:layout_alignTop="@+id/textViewCursoPerfilV"
                android:layout_marginTop="45dp"
                android:layout_marginLeft="20dp"
                android:layout_alignParentStart="true" />
        </RelativeLayout>
    </ScrollView>
</RelativeLayout>

Upvotes: 1

Views: 109

Answers (3)

Pratik Butani
Pratik Butani

Reputation: 62419

Try it. I just removed Parent Layout RelativeLayout:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <Button
            android:id="@+id/buttonHomePerfilV"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="81dp"
            android:layout_height="61dp"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="20dp"
            android:background="#333399"
            android:text="@string/Texto14"
            android:textColor="#ffffff" />

        <Button
            android:id="@+id/buttonIniciarConversaPerfilV"
            android:layout_width="291dp"
            android:layout_height="wrap_content"
            android:layout_above="@+id/buttonIDAmizadePerfilV"
            android:layout_alignBottom="@+id/buttonIDAmizadePerfilV"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="70dp"
            android:background="#333399"
            android:text="@string/Texto15"
            android:textColor="#ffffff" />

        <Button
            android:id="@+id/buttonIDAmizadePerfilV"
            android:layout_width="291dp"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignStart="@+id/buttonIniciarConversaPerfilV"
            android:layout_marginBottom="20dp"
            android:background="#333399"
            android:text="@string/Texto16"
            android:textColor="#ffffff" />

        <ImageView
            android:id="@+id/imageViewPerfilV"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_below="@+id/buttonHomePerfilV"
            android:layout_centerHorizontal="true"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/textViewNomePerfilV"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignStart="@+id/buttonHomePerfilV"
            android:layout_below="@+id/imageViewPerfilV"
            android:layout_marginTop="20dp"
            android:text="@string/Texto8"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textViewCursoPerfilV"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignStart="@+id/textViewNomePerfilV"
            android:layout_centerVertical="true"
            android:layout_toEndOf="@+id/buttonHomePerfilV"
            android:text="@string/Texto9"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textViewDataPerfilV"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_alignTop="@+id/textViewCursoPerfilV"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="45dp"
            android:text="@string/Texto10"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </RelativeLayout>

</ScrollView>

Upvotes: 1

LMK
LMK

Reputation: 2962

Try this

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
    <Linearlayout>
     <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <Button
            style="?android:attr/buttonStyleSmall"
            android:layout_width="81dp"
            android:layout_height="61dp"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="20dp"
            android:text="@string/Texto14"
            android:id="@+id/buttonHomePerfilV"
            android:textColor="#ffffff"
            android:background="#333399"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true" />

        <Button
            android:layout_width="291dp"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/buttonIDAmizadePerfilV"
            android:layout_marginBottom="70dp"
            android:text="@string/Texto15"
            android:id="@+id/buttonIniciarConversaPerfilV"
            android:textColor="#ffffff"
            android:background="#333399"
            android:layout_above="@+id/buttonIDAmizadePerfilV"
            android:layout_centerHorizontal="true" />
        <Button
            android:layout_width="291dp"
            android:layout_height="wrap_content"
            android:text="@string/Texto16"
            android:id="@+id/buttonIDAmizadePerfilV"
            android:layout_marginBottom="20dp"
            android:textColor="#ffffff"
            android:background="#333399"
            android:layout_alignParentBottom="true"
            android:layout_alignStart="@+id/buttonIniciarConversaPerfilV" />

        <ImageView
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:id="@+id/imageViewPerfilV"
            android:src="@drawable/ic_launcher"
            android:layout_below="@+id/buttonHomePerfilV"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/Texto8"
            android:id="@+id/textViewNomePerfilV"
            android:layout_below="@+id/imageViewPerfilV"
            android:layout_alignStart="@+id/buttonHomePerfilV" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/Texto9"
            android:id="@+id/textViewCursoPerfilV"
            android:layout_toEndOf="@+id/buttonHomePerfilV"
            android:layout_centerVertical="true"
            android:layout_alignStart="@+id/textViewNomePerfilV" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/Texto10"
            android:id="@+id/textViewDataPerfilV"
            android:layout_alignTop="@+id/textViewCursoPerfilV"
            android:layout_marginTop="45dp"
            android:layout_marginLeft="20dp"
            android:layout_alignParentStart="true" />
    </RelativeLayout>

 </linearlayout>
</scrollview>

Upvotes: 0

MineConsulting SRL
MineConsulting SRL

Reputation: 2340

You cannot use a RelativeLayout inside a ScrollView put the RelativeLayout inside a LinearLayout

Upvotes: 1

Related Questions