How could I make an image inside a ScroolView stay fixed and all content "scroll" down "from the image?

2

Hello, I would like to know how I could do to keep a still image and the information roll underneath it, with all of that inside a ScrollView, follows layout and XML print

Code:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"> 
<LinearLayout
    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="com.hs.gui.testelayout.TelaTres"
    android:orientation="vertical"> 
<TextView
    android:layout_width="100dp"
    android:layout_height="15dp"
    android:text="Tela 3 - | - Final"/>
<ImageView
    android:layout_width="350dp"
    android:layout_height="250dp"
    android:paddingLeft="15dp"
    android:paddingRight="15dp"
    android:paddingBottom="15dp"
    android:foregroundGravity="center"
    android:src="@drawable/guerra_civil_2"
    android:scrollIndicators="start"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/sinopse_CivWar"
    android:textSize="25dp"/>
</LinearLayout>
</ScrollView>

I thought about keeping the image out of ScrollView but this does not seem possible (or I do not know how to do) Thank you for your attention:)

    
asked by anonymous 12.04.2016 / 21:36

2 answers

1

I managed to transform the main layout into LinearLayout , and put the static elements in the beginning. Then I put the ScrollView with the only element scrolavel that was the synopsis:

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

  <!--Elementos Estaticos-->
    <TextView
        android:layout_width="100dp"
        android:layout_height="15dp"
        android:text="@string/titulo"/>


    <ImageView
        android:layout_width="350dp"
        android:layout_height="250dp"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:paddingBottom="15dp"
        android:src="@drawable/civilwar"/>

       <!--Elementos Moveis-->
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/sinopse_CivWar"
                android:textSize="25dp"/>

        </LinearLayout>

    </ScrollView>
</LinearLayout>

Follow print:

    
14.04.2016 / 04:36
1

To do this, you must use a RelativeLayout

Example:

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

    <!-- Imagem fora do ScrowView, fica fixa -->
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/imageView"
        android:src="@mipmap/ic_launcher"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/scrollView"
        android:background="@android:color/transparent"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" >

        <LinearLayout
            android:orientation="horizontal"
            android:background="@android:color/transparent"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <!-- Coloque aqui os TextView-->

            <TextView
                android:layout_width="301dp"
                android:layout_height="1680dp"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/texto"
                android:id="@+id/textView"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_marginLeft="38dp"
                android:layout_marginStart="38dp"
                android:layout_marginTop="103dp" />


        </LinearLayout>
    </ScrollView>

</RelativeLayout>
    
12.04.2016 / 21:51