android 布局之scrollview
今天在布局页面的时候后犯了难,我要显示的内容一个页面展示不完,怎么办呢?
于是随便找了个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的更多相关文章
- Android布局中ScrollView与ListView的冲突的最简单方法
看到网上流行的一种使用方法是: public class Utility { public static void setListViewHeightBasedOnChildren(ListView ...
- android 布局文件 ScrollView 中的 listView item 显示不全解决方案
import android.content.Context;import android.util.AttributeSet;import android.widget.ListView; /** ...
- Android UI系列-----ScrollView和HorizontalScrollView
本篇随笔将讲解一下Android当中比较常用的两个布局容器--ScrollView和HorizontalScrollView,从字面意义上来看也是非常的简单的,ScrollView就是一个可以滚动的V ...
- Android开发:ScrollView嵌套GridView的解决办法
Android开发:ScrollView嵌套GridView的解决办法 前些日子在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便 ...
- Android 布局 中实现适应屏幕大小及组件滚动
要实现如图的布局: 这是在eclipse可视化窗口中的截图,但实际运行在Android设备上可能出现的问题有: (1):当编辑图1中的最后一个EditText时,输入法的编辑界面会把底部的Button ...
- Android 布局学习之——Layout(布局)具体解释二(常见布局和布局參数)
[Android布局学习系列] 1.Android 布局学习之--Layout(布局)具体解释一 2.Android 布局学习之--Layout(布局)具体解释二(常见布局和布局參数) ...
- [Android] Android最简单ScrollView和ListView滚动冲突解决方案
[Question]问题描述: 单独的ListView列表能自动垂直滚动,但当将ListView嵌套在ScrollView后,会和ScrollView的滚动滑块冲突,造成ListView滑块显示不完整 ...
- Android 布局学习之——Layout(布局)详解二(常见布局和布局参数)
[Android布局学习系列] 1.Android 布局学习之——Layout(布局)详解一 2.Android 布局学习之——Layout(布局)详解二(常见布局和布局参数) 3.And ...
- Android 布局控件——滚动条视图,日期,时间
今天学长讲了一些控件,比较强的那种控件. 刚开始讲了图片,但是图片我前面写过了就跳过. 滚动条牛牛们应该很熟悉,也常用哈. 这是垂直的滚动条视图哈 一起来用吧! <ScrollView andr ...
随机推荐
- 解析json格式数据
实现目标 读取文件中的json格式数据,一行为一条json格式数据.进行解析封装成实体类. 通过google的Gson对象解析json格式数据 我现在解析的json格式数据为: {",&qu ...
- C++ 中指针与引用的区别
指向不同类型的指针的区别在于指针类型可以知道编译器解释某个特定地址(指针指向的地址)中的内存内容及大小,而void*指针则只表示一个内存地址,编译器不能通过该指针所指向对象的类型和大小,因此想要通过v ...
- 理解 Linux 网络栈(3):QEMU/KVM + VxLAN 环境下的 Segmentation Offloading 技术(发送端)
本系列文章总结 Linux 网络栈,包括: (1)Linux 网络协议栈总结 (2)非虚拟化Linux环境中的网络分段卸载技术 GSO/TSO/UFO/LRO/GRO (3)QEMU/KVM + Vx ...
- 2014 UESTC暑前集训数据结构专题解题报告
A.Islands 这种联通块的问题一看就知道是并查集的思想. 做法:从高水位到低水位依序进行操作,这样每次都有新的块浮出水面,可以在前面的基础上进行合并集合的操作.给每个位置分配一个数字,方便合并集 ...
- CF 375B Maximum Submatrix 2[预处理 计数排序]
B. Maximum Submatrix 2 time limit per test 2 seconds memory limit per test 512 megabytes input stand ...
- AC日记——最长最短单词 openjudge 1.7 25
25:最长最短单词 总时间限制: 1000ms 内存限制: 65536kB 描述 输入1行句子(不多于200个单词,每个单词长度不超过100),只包含字母.空格和逗号.单词由至少一个连续的字母构成 ...
- JavaScript RegExp 对象
JavaScript RegExp 对象 RegExp 对象用于规定在文本中检索的内容. 什么是 RegExp? RegExp 是正则表达式的缩写. 当您检索某个文本时,可以使用一种模式来描述要检索的 ...
- java 28 - 5 JDK5的新特性 之 枚举的使用
上一章,自定义了枚举类,超级麻烦.. 所以,JAVA给了一个枚举类:类 Enum<E extends Enum<E>> 注意事项 定义枚举类要用关键字enum 所有枚举类都是E ...
- ubuntu系统下的防火墙使用
apt-get install ufw 安装防火墙sudo ufw enable|disable|status 开启/关闭/查看防火墙状态sudo ufw allow 22/ ...
- Centos 检查磁盘读写性能
启动Tomcat发现deploy war的速度明显变慢, 怀疑磁盘出问题 测试写入 [tomcat@localhost ~]$ dd if=/dev/zero of=kwxgd bs=64k coun ...