今天在布局页面的时候后犯了难,我要显示的内容一个页面展示不完,怎么办呢?

于是随便找了个app点开一看,哎呀原来还能翻动啊!这是啥布局呢?原来是ScrollView

官方api相关的内容全是英文,这可让三级b的我头大了好一通,不过没关系,不是有国内大神嘛

原来这个布局用法还真是粗暴:

加上标签<scrollview .....></scrollview>

就能用了,不过在宽度和高度的设置方面要注意,高度是万万不能是match_parent的

因为如果这样你会发现额啥都没了。这也很好理解因为控件本身不限制高度,如果你自己再不限制(充满)

自然就没有高度。

废话不多说:

直接上布局吧:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/normalbackground"
android:gravity="center"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/more_username"
android:text="王大锤"
android:textColor="#ffffff"
android:textSize="30dp"/> </LinearLayout> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:layout_gravity="center_vertical"> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拿快递"
android:textSize="30dp"
android:textColor="#000000"
android:id="@+id/more_title"
android:paddingTop="5dp"
android:paddingLeft="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="right"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥"
android:textColor="#ff0000"
android:textSize="30dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:textSize="30dp"
android:textColor="#ff0000"
android:id="@+id/more_price"
android:paddingRight="10dp"/>
</LinearLayout> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="horizontal"> <ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/ic_menu_camera"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="说明:"
android:paddingLeft="5dp"
android:textSize="25dp"/> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="前门天天快递 , 细节再聊"
android:id="@+id/more_explain"
android:textSize="20dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingTop="10dp"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2015-12-6 09:30 ~ 12:00"
android:id="@+id/more_date"
android:paddingRight="10dp"
android:textSize="15dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"> <ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/ic_menu_gallery"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="收货地址:"
android:textSize="25dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="南信院 4#406B 我辈年轻收
askdfjalkfj
adsdfaddf
adssfasdff
asdffasdf"
android:textSize="20dp"
android:id="@+id/more_add"/>
</LinearLayout> <ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView"
android:layout_gravity="right" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="20dp"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="电话:123456789001"
android:id="@+id/more_phone"
android:background="#ff6666"
android:textSize="20dp"/> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"> <Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="细聊"
android:id="@+id/more_chat"
android:background="#ccff99"
android:textSize="20dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/more_jie"
android:background="#6699cc"
android:text="接单"
android:textSize="20dp"/> </LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView>

android 布局之scrollview的更多相关文章

  1. Android布局中ScrollView与ListView的冲突的最简单方法

    看到网上流行的一种使用方法是: public class Utility { public static void setListViewHeightBasedOnChildren(ListView ...

  2. android 布局文件 ScrollView 中的 listView item 显示不全解决方案

    import android.content.Context;import android.util.AttributeSet;import android.widget.ListView; /** ...

  3. Android UI系列-----ScrollView和HorizontalScrollView

    本篇随笔将讲解一下Android当中比较常用的两个布局容器--ScrollView和HorizontalScrollView,从字面意义上来看也是非常的简单的,ScrollView就是一个可以滚动的V ...

  4. Android开发:ScrollView嵌套GridView的解决办法

    Android开发:ScrollView嵌套GridView的解决办法   前些日子在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便 ...

  5. Android 布局 中实现适应屏幕大小及组件滚动

    要实现如图的布局: 这是在eclipse可视化窗口中的截图,但实际运行在Android设备上可能出现的问题有: (1):当编辑图1中的最后一个EditText时,输入法的编辑界面会把底部的Button ...

  6. Android 布局学习之——Layout(布局)具体解释二(常见布局和布局參数)

     [Android布局学习系列]   1.Android 布局学习之--Layout(布局)具体解释一   2.Android 布局学习之--Layout(布局)具体解释二(常见布局和布局參数)   ...

  7. [Android] Android最简单ScrollView和ListView滚动冲突解决方案

    [Question]问题描述: 单独的ListView列表能自动垂直滚动,但当将ListView嵌套在ScrollView后,会和ScrollView的滚动滑块冲突,造成ListView滑块显示不完整 ...

  8. Android 布局学习之——Layout(布局)详解二(常见布局和布局参数)

    [Android布局学习系列]   1.Android 布局学习之——Layout(布局)详解一   2.Android 布局学习之——Layout(布局)详解二(常见布局和布局参数)   3.And ...

  9. Android 布局控件——滚动条视图,日期,时间

    今天学长讲了一些控件,比较强的那种控件. 刚开始讲了图片,但是图片我前面写过了就跳过. 滚动条牛牛们应该很熟悉,也常用哈. 这是垂直的滚动条视图哈 一起来用吧! <ScrollView andr ...

随机推荐

  1. 系统进程 zygote(一)—— 概述

    和蔼的春光,充满鸳鸯的池塘:快辞别寂寞的梦乡,来和我摸一会鱼儿,折一枝海棠.—— 徐志摩·醒!醒! ilocker:关注 Android 安全(新入行,0基础) QQ: 2597294287 先看一张 ...

  2. 修改TFS客户端的工作区类型

    TFS系统存在两种工作区类型:"​本地"和"服务器".默认情况下,用户使用本地工作区实现代码管理. 但是在用户端代码文件特别多(超过10万个文件)时,由于每次启 ...

  3. [转]Backbone.js简单入门范例

    本文转自:http://dmyz.org/archives/598 11年刚开始用前端MVC框架时写过一篇文章,当时Knockout和Backbone都在用,但之后的项目全是在用Backbone,主要 ...

  4. Jetty使用攻略

    jetty作为一款小型的web容器用处很大,因为其小巧强大,经常作为嵌入式的组件处理http交互. Jetty 作为一个独立的 Servlet 引擎可以独立提供 Web 服务,但是它也可以与其他 We ...

  5. SoapUI调用webservice实现的两种方式

    SoapUI用来做测试,已经是很多人做过的事情了,而且网上教程也很多.不过还是写下来,对比webservice协议与http协议脚本编写的不同. 首先测接口得有一个服务,刚好笔者所在项目做ESB集成. ...

  6. javascript_core之正则、Math、Date

      javascript_core之正则.Math.Date 1.RegExp:Regular Expression,创建封装正则表达式: ①正则直接量:var reg=/reg/ig:②var re ...

  7. [No000026]365种创业、办公、和生活成长的精华资源

    只需要具备以下技能,人人都可以成为企业家:经得起失败的考验,思维活跃,新点子不断,能够脚踏实地把新点子转化为产品,并在这个过程中坚持不懈,百折不挠,即使跌倒了,也要及时从失败中学习,迅速投入到下一次冒 ...

  8. Javascript Window的属性

    Window的属性 属性 描述 closed 获取引用窗口是否已关闭. defaultStatus 设置或获取要在窗口底部的状态栏上显示的缺省信息. dialogArguments 设置或获取传递给模 ...

  9. bzoj1036 [ZJOI2008]树的统计Count

    1036: [ZJOI2008]树的统计Count Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 12646  Solved: 5085 [Subm ...

  10. EditText限制输入字符类型的几种方式

    最近的项目上需要限制EditText输入字符的类型,就把可以实现这个功能的方法整理了一下: 1.第一种方式是通过EditText的inputType来实现,可以通过xml或者Java文件来设置.假如我 ...