0

Meine Absicht Nesting ist durch Verschachtelung es in einem ScrollView meine TextView scrollbaren zu machen (obwohl ich weiß, dass TextView kann allein scrollbaren gemacht werden (ohne einen Elternteil ScrollView) zu benötigen, wollte ich es tun in auf diese Weise :)) und haben die ScrollView füllen Sie die gesamte Breite des Bildschirms. Das Layout im folgenden Code funktioniert, aber ScrollView füllt nicht die gesamte Breite des Bildschirms. Sein Elternteil füllt jedoch die gesamte Breite.eine Scrollview in einem TableRow

I haben versucht, die Werte der von android:layout_widthScrollView mit fill_parent, match_parent und wrap_content Substitution, aber keiner von ihnen sind die Breite vollständig zu füllen.

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:showIn="@layout/activity_my"> 

    <TableRow> 
     <EditText android:id="@+id/edit_message" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:hint="@string/edit_message" 
      android:layout_weight="1"/> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="@string/button_send" 
      android:onClick="sendMessage"/> 
    </TableRow> 

    <TableRow> 
     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:scrollbars="vertical" 
      android:fillViewport="true"> 
      <TextView 
       android:id="@+id/message_box" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" /> 
     </ScrollView> 
    </TableRow> 

</TableLayout> 

Antwort

1

Ich fand eine Lösung! Ich fügte android:layout_weight="1" zu ScrollView hinzu.

<ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="vertical" 
     android:layout_weight="1" 
     android:fillViewport="true"> 
     <TextView 
      android:id="@+id/message_box" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 
</ScrollView>