How to use ScrollView in Android?

前端 未结 8 1563
抹茶落季
抹茶落季 2020-11-22 11:41

I have an XML layout file, but the text is more than fits into the screen size. What do I need to do in order to make a ScrollView?



        
相关标签:
8条回答
  • 2020-11-22 12:41

    Just make the top-level layout a ScrollView:

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
    
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:stretchColumns="1">
    
            <!-- everything you already have -->
    
        </TableLayout>
    </ScrollView>
    
    0 讨论(0)
  • 2020-11-22 12:42
    <?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" >
    
        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:stretchColumns="1" >
    
            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
    
                <RadioGroup
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent" >
    
                    <RadioButton
                        android:id="@+id/butonSecim1"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:layout_weight=".50"
                        android:text="@string/buton1Text" />
    
                    <RadioButton
                        android:id="@+id/butonSecim2"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:layout_weight=".50"
                        android:text="@string/buton2Text" />
                </RadioGroup>
            </TableRow>
    
            <TableRow
                android:id="@+id/tableRow2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
    
                <TableLayout
                    android:id="@+id/bilgiAlani"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:visibility="invisible" >
    
                    <TableRow
                        android:id="@+id/BilgiAlanitableRow2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >
    
                        <TextView
                            android:id="@+id/bilgiMesaji"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_weight=".100"
                            android:ems="10"
                            android:gravity="left|top"
                            android:inputType="textMultiLine" />
                    </TableRow>
                </TableLayout>
            </TableRow>
    
            <TableRow
                android:id="@+id/tableRow3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
    
                <TextView
                    android:id="@+id/metin4"
                    android:layout_height="match_parent"
                    android:layout_weight=".100"
                    android:text="deneme" />
            </TableRow>
    
            <TableRow
                android:id="@+id/tableRow4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
    
                <TextView
                    android:id="@+id/metin5"
                    android:layout_height="match_parent"
                    android:layout_weight=".100"
                    android:text="deneme" />
            </TableRow>
        </TableLayout>
    
    </ScrollView>
    
    0 讨论(0)
提交回复
热议问题