Search code examples
androidandroid-layouttextviewscrollview

TextView is not fit in ScrollView


I have a problem that TextView doesn't match with ScrollView ...

Here is my code:

<ScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/scrollViewSlide"
            tools:ignore="UselessParent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center">

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:layout_gravity="center_vertical|center_horizontal"
                    android:id="@+id/txtPassage"
                    android:textAlignment="center"
                    android:textIsSelectable="true"
                    android:textColor="#ffffff"
                    android:textSize="15sp"
                    tools:ignore="UnusedAttribute" />

            </LinearLayout>

        </ScrollView>

s.th that shows and is false (better to say in this way that about 5 first line is hidden)enter image description here


Solution

  • try this

        <ScrollView
        android:layout_width="match_parent"
        android:fillViewport="true"
        android:layout_height="match_parent">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/li1"
            android:orientation="vertical">
    
            <TextView
                android:layout_width="match_parent"
                android:text="Hellofgbjfdkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkhbhbghbuuuuuuuuuuuuuuuubfiiiiiiiiiibigyygfjjjjjjjjjjjjjjjjjjjjjjjjjj\nfjgggggggggggggggg\ngfggggggggggggggggggg\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\njgjijhijghijgfhjgfhjigfjhijgfhjgi
                jfdjgkfjd\nkkgkfgklfkgfg"
                android:layout_height="match_parent" />
        </LinearLayout>
    
    </ScrollView>