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

时间:2019-01-23 17:38:55

标签: java android xml scrollview

我现在想用代码视图在片段中显示我的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;
}

1 个答案:

答案 0 :(得分:0)

不要弄乱水平和垂直滚动视图。这是很好的library。试试看。

“ Android的双向平移容器,具有API 7及更高版本的本地滚动。”

相关问题