I have a rather complex layout where I mainly show a picture with text over it (overlapped) and some buttons at the bottom. I set the text dynamically, and in some cases it exceeds TextBox heigtht, so I decided to add a ScrollView, but no matter what I try, ScrollView will never work (scroll) and the "hidden" text will never be displayed.
I have read all related StackOverflow posts with no luck, I've also tried android:fillViewport="true" with no luck also and no luck with android:windowSoftInputMode="adjustResize|stateHidden" in AndroidManifest.
Any other ideas?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/gradient_background">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="invisible"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:id="@+id/rlThought">
<ImageView
android:id="@+id/ivBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:contentDescription="@string/desc"
android:scaleType="centerCrop"
android:cropToPadding="true"
android:background="@drawable/frame_border_phone" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tvThought"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:shadowColor="#000"
android:shadowDx="2"
android:shadowDy="2"
android:shadowRadius="6"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:textColor="#FFF"
android:textSize="28sp"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="@+id/llFrameInfo"
android:orientation="vertical">
<!--llSignature-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/llSignature"
android:orientation="horizontal">
<TextView
android:id="@+id/tvSignaturePrefix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:textStyle="bold"
android:textSize="12sp" />
<TextView
android:id="@+id/tvSignature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:textSize="12sp" />
</LinearLayout>
<!--llTrackDetails-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/llTrackDetails"
android:visibility="gone"
android:paddingBottom="1dp"
android:layout_below="@id/llSignature"
android:orientation="horizontal">
<TextView
android:id="@+id/tvTrackDetailsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:textStyle="bold"
android:textSize="12sp" />
<TextView
android:id="@+id/tvTrackDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:textSize="12sp" />
</LinearLayout>
<!--Copyright-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/llCopyright"
android:layout_below="@id/llTrackDetails"
android:orientation="horizontal">
<TextView
android:id="@+id/tvCopyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="@+id/animOverlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:contentDescription="@string/desc"
android:scaleType="centerCrop"
android:cropToPadding="true"
android:visibility="invisible" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/llBottomMenu"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/ivShareImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:src="@drawable/menu_share"
android:contentDescription="@string/thought_share" />
<ImageView
android:id="@+id/ivShareVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:src="@drawable/menu_share"
android:contentDescription="@string/thought_share" />
<ImageView
android:id="@+id/ivSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginLeft="8dp"
android:src="@drawable/save"
android:contentDescription="@string/thought_save" />
<ImageView
android:id="@+id/ivPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginLeft="10dp"
android:src="@drawable/play"
android:contentDescription="@string/track_play" />
<ImageView
android:id="@+id/ivPause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginLeft="10dp"
android:src="@drawable/pause"
android:contentDescription="@string/track_stop" />
<Spinner
android:id="@+id/animSpinner"
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="35dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Edit 1:
OK, after long time of trial and error I got ScrollView partially working. I have removed the second RelativeLayout (counting from top) and don't know why but started to work, but the problem now is that you see the text cut and not full text, even that you can scroll :s
In my particular case setting the ScrollView content (TextView in my case) layout_height as "wrap_content" was causing ScrollView not to scroll (why???) while if I set a fixed value scroll starts working, so in the end, what I've done to make it to work, was to calculate ScrollView content in code and set its layout_height dynamically.
Calculating ScrollView content height dynamically was a rather complex task, as I needed to do it before views are rendered, but this is subject for another thread :), the fact is calculating content height and setting its layout_height dynamically have done the trick for me.