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 ...
随机推荐
- 二:C语言(分之结构)
一:if语句 二:while语句 #include <stdio.h> int main() { ; i=; ) //循环条件应该是什么呢? { sum=sum+i; i++ ; //这里 ...
- Nova 操作汇总(限 libvirt 虚机) [Nova Operations Summary]
本文梳理一下 Nova 主要操作的流程. 0. Nova REST-CLI-Horizon 操作对照表 Nova 基本的 CRUD 操作和 extensions: # 类别 Nova V2 REST ...
- 学习OpenStack之 (1):安装devstack
1. 系统准备 ubuntu 12.04 server 虚拟机. 2G内存. 依次运行以下命令来安装git: sudo apt-get update sudo apt-get upgrade sudo ...
- NOIP2010提高组乌龟棋 -SilverN
题目背景 小明过生日的时候,爸爸送给他一副乌龟棋当作礼物. 题目描述 乌龟棋的棋盘是一行N个格子,每个格子上一个分数(非负整数).棋盘第1格是唯一的起点,第N格是终点,游戏要求玩家控制一个乌龟棋子从起 ...
- hdu-5127------hdu5137
hdu-5127 思路: 本来正解好像是动态凸包,暴力10000+ms可以搞过去; hdu-5128 思路: 枚举两个长方形的对角线,然后判断是否不相交,更新答案就好; hdu-5130 思路: 将题 ...
- UVA 10375 Choose and divide【唯一分解定理】
题意:求C(p,q)/C(r,s),4个数均小于10000,答案不大于10^8 思路:根据答案的范围猜测,不需要使用高精度.根据唯一分解定理,每一个数都可以分解成若干素数相乘.先求出10000以内的所 ...
- NOIP2003传染病控制[按层DFS]
题目背景 近来,一种新的传染病肆虐全球.蓬莱国也发现了零星感染者,为防止该病在蓬莱国大范围流行,该国政府决定不惜一切代价控制传染病的蔓延.不幸的是,由于人们尚未完全认识这种传染病,难以准确判别病毒携带 ...
- 维护MMO项目的随想
前提条件 近期我的工作内容是在维护一个历经几年的MMORPG大型项目,写下自己的一些感想 项目进度:游戏中基本的系统功能都有了,现阶段的主要工作就是修复系统的bug及重构部分系统. 维护老项目从何开始 ...
- [No00001D]解决5个问题,马上开口说英语
- java 23 - 2 设计模式之单例模式
单例模式:保证类在内存中只有一个对象. 如何保证类在内存中只有一个对象呢? A:把构造方法私有 B:在成员位置自己创建一个对象 C:通过一个公共的方法提供访问 单例模式之饿汉式: (一进来就造对 ...