scrollview横向滑动(scrollview)

你们好,最近小未来发现有诸多的小伙伴们对于scrollview横向滑动,scrollview这个问题都颇为感兴趣的,今天小活为大家梳理了下,一起往下看看吧。

1、 首先打开android主xml布局文件。

2、 找到滚动视图并将其添加到视图中。

3、 主要布局文件代码关键部分:

4、 ScrollView android:id='@+id/scrollView' android:layout_width='match_parent' android:layout_height='wrap_content' android:fadeScrollbars='false'TextView android:id='@+id/textView1' android:layout_width='wrap_content' android:layout_height='wrap_content' android:text='Hello World!' app:layout_constraintBottom_toBottomOf='parent' app:layout_constraintLeft_toLeftOf='parent' app:layout_constraintRight_toRightOf='parent' app:layout_constraintTop_toTopOf='parent' //ScrollView

5、 然后在strings.xml中设置文本内容。

6、 回到主活动,将如图所示的代码添加到它的Java代码中:

7、 主要是先找到viewbyid,然后直接操作textview。

8、 oncreate部分

9、 :

10、 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView=findViewById(R.id.textView1); contents=new StringBuilder(); for(int i=0;i=1000;i++) contents.append(R.string.content); textView.setText(contents);}

11、 当然,我们也可以通过如何使用Android中的滚动视图组件来设置侧边滚动条的状态。

12、 最终实现效果

以上就是scrollview这篇文章的一些介绍,希望对大家有所帮助。

免责声明:本文章由会员“马楠一”发布如果文章侵权,请联系我们处理,本站仅提供信息存储空间服务如因作品内容、版权和其他问题请于本站联系

马楠一
免责声明:本文章由会员“马楠一”发布,如果文章侵权,请联系我们处理,本站仅提供信息存储空间服务;如因作品内容、版权和其他问题请于本站联系