ScrollView don't scroll?

2019-05-21 05:24发布

问题:

I've a ScrollView / RelativeLayout / FrameLayout and I inside put programmaticaly some widgets.

Here is the gui xml :

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="@drawable/fond_app">
  <RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  >
   <TextView
   android:id="@+id/titreAppli"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="My Big Application" 
   android:textStyle="bold"
   android:textColor="#9b9b71"
   android:textSize="15dp"
   />
   <FrameLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:id="@+id/out"
   android:layout_below="@id/titreAppli"
   />
  </RelativeLayout>
</ScrollView> 

In the FrameLayout, I put programaticaly another RelativeLayout, and other widgets inside.

With some widgets (text, image, buttons), I can't scroll. With other (a linearlist with text), I can scroll.

Why ? Is there a solution ?

Thanks.

回答1:

Have you tried without the android:fillViewport="true" ?



回答2:

First remove frame layout. You should use some other layout like relative instead of framelayout. Becasue Framelayout is not expanding and there fore scroll view is not working. If you use linear or relative then they will expand and you will be able to scroll.