水平和垂直滚动。如何在代码视图中显示我的 java 代码并水平和垂直滚动我的代码?

Scrolling Both horizontally and vertically . how can i show my java code in a code view and scroll my code both horizontally and vertically?

我想在带有代码视图的片段中显示我的 java 代码,现在我的问题是我的代码只执行向下滚动,但我想滚动可能同时水平和垂直编码,所以现在我能做什么?

我已经尝试过嵌套 horizo​​ntalscrollview 和 scrollview,但它不起作用,我的应用程序崩溃了。

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="saiful" />

        <thereisnospon.codeview.CodeView
            android:id="@+id/codeViewId"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </thereisnospon.codeview.CodeView>


    </LinearLayout>

</ScrollView>

我的 java 文件是

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_java, container, false);

    codeView = view.findViewById(R.id.codeViewId);
    codeView.setTheme(CodeViewTheme.ANDROIDSTUDIO).fillColor();
    codeView.showCode(Content.java);
    return view;
}

不要混淆水平和垂直滚动视图。这是很好的library。试一试。

"A bidirectional panning container for Android with native scrolling for APIs 7 and up."