安卓解决一屏控件太多无法显示完的问题

安卓解决一屏控件太多无法显示完的问题

在使用Android Studio进行安卓软件开发时,你是不是也习惯用LinearLayout布局来作为父布局,然后通过调整控件的大小来实现不同尺寸手机的适配呢许在控件少和控件大小没有要求的情况下这种方案是完全可以的,但是当一屏的控件变得很多或者对某些控件的大小有明确要求的时候,那么这时在用上述的方案就将出现控件丢失或者某些控件元素显示不完全的尴尬局面。那么我们又该如何去解决这个问题呢时就要用到一个非常神奇的布局了,没错就是ScrollView。接下来我将分别展示他的三种基本用法。


1. 竖屏可滑动扩展(Vertical)

2. 横屏滑动可扩展(Horizontal)
/span>xml version="1.0" encoding="utf-8"/span>>LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    tools:context=".HorizontalActivity">    TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="50dp"android:gravity="center"android:text="这是Horizontal页面!"android:textSize="30sp"/>    HorizontalScrollViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:scrollbars="none">LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:orientation="horizontal">    Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:text="测试按钮">    /Button>    Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:text="测试按钮">    /Button>    Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:text="测试按钮">    /Button>    Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:text="测试按钮">    /Button>    Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:text="测试按钮">    /Button>    Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:text="测试按钮">    /Button>    Button android:layout_width="match_parent" android:layout_height

                                                        

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年10月17日
下一篇 2020年10月17日

相关推荐