How to use scrollview over codeview?

78 Views Asked by At

i'm building an tutorial app where im displaying code snippet to user, but scrolling is just working on white area of the screen but not over the code snippet, may be codeview is overlapping the scrollview, How to resolve it so the codeview also scroll:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="activity_main.xml"
            android:textColor="@android:color/black"
            android:textStyle="bold"
            android:layout_marginTop="5dp"
            android:textSize="18sp"/>

        <io.github.kbiakov.codeview.CodeView
            android:id="@+id/code_view_xml"
            android:layout_marginTop="7dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="create layout resource file inside layout directory with name:"
            android:layout_marginTop="10dp"
            android:textColor="#000000"
            android:textStyle="italic"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="single_item.xml"
            android:textColor="@android:color/black"
            android:textStyle="bold"
            android:layout_marginTop="5dp"
            android:textSize="18sp"/>

        <io.github.kbiakov.codeview.CodeView
            android:id="@+id/code_view_item"
            android:layout_marginTop="7dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>


    </LinearLayout>

</ScrollView>

here the output :

screenshot

1

There are 1 best solutions below

1
Khar Varsha On

You are missing padding. Try adding padding. Also your linearlayout height is match_parent. Change that to wrap and then try