2012-09-25 2 views
1

je tente d'utiliser ScrollView et un TableLayout intérieur de ScrollView comme ceci:Android: ScrollView ne fonctionne pas avec TableLayout

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" > 

    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <TableRow 
      android:id="@+id/tableRow1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Input text: " /> 

      <EditText 
       android:id="@+id/weightEditText" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:inputType="numberDecimal" > 

       <requestFocus /> 
      </EditText> 
     </TableRow> 

    </TableLayout> 

</ScrollView> 

Mais cela ne fonctionne pas. Les barres de défilement ne s'affichent pas même si mon contenu est trop volumineux. Est-ce que quelqu'un a des suggestions pour lesquelles cela fonctionne comme ça?

Répondre

3

Essayez de changer le layout_height de scrollview à match_parent comme ceci:

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_margin="10dp" > 

Lorsque vous utilisez wrap_content votre scrollview va juste grandir, même lorsque les extrémités écran, mais lorsque vous utilisez match_parent votre scrollview s'adapter à l'écran et lorsque la le contenu des débordements de scrollview montrera des barres de défilement.

Rolf

+0

Cela fonctionne, merci! – JavaRunner

Questions connexes