单页图片和文字一起滑动的效果
2015-06-30 01:56
330 查看
由于项目中需要展示各个展馆的文字介绍以及上方配的图片,所以写此文章,记录一下,以方便以后的使用。
刚开始由于不知道最外层应该是ScrollView,所以在LinearLayout中套了一个ScrollView,导致ScrollView can host only one direct child 错误。所以在搜索了如何实现滑动图片的资源以后,首先发现最外层最好直接是ScrollView,其次可以在ImageView和TextView外层套一个LInearLayout,这个问题就解决了。
下面是XML文件。
其次呢,ImageVIew经常会报Missing contentDescription attribute on image这个警告,主要是由于ADT会提示你定义一个android:contentDescription属性,用来描述这个控件的作用。也就是对这个控件作用的描述,随便加上一句即可,例如:android:contentDescription="@string/app_name"。
从写此页面的经历,我体会到了人不能被惯性思维所约束,不能平时习惯怎样,就认为所有的事情也应该是这样的。程序员就应该有创新意识,打破惯性思维,敢想敢试,这样才会有更大的进步。
刚开始由于不知道最外层应该是ScrollView,所以在LinearLayout中套了一个ScrollView,导致ScrollView can host only one direct child 错误。所以在搜索了如何实现滑动图片的资源以后,首先发现最外层最好直接是ScrollView,其次可以在ImageView和TextView外层套一个LInearLayout,这个问题就解决了。
下面是XML文件。
<?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="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="match_parent" android:layout_height="200dip" android:scaleType="fitXY" android:src="@drawable/six"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hello_world"/> </LinearLayout> </LinearLayout> </ScrollView>
其次呢,ImageVIew经常会报Missing contentDescription attribute on image这个警告,主要是由于ADT会提示你定义一个android:contentDescription属性,用来描述这个控件的作用。也就是对这个控件作用的描述,随便加上一句即可,例如:android:contentDescription="@string/app_name"。
从写此页面的经历,我体会到了人不能被惯性思维所约束,不能平时习惯怎样,就认为所有的事情也应该是这样的。程序员就应该有创新意识,打破惯性思维,敢想敢试,这样才会有更大的进步。
相关文章推荐
- Mybatis一对一和一对多配置
- Android.Ant.Python之批量打包(一)
- php 用for循环做,金字塔,菱形,空三角
- IDA一日速成整理笔记
- codeforces 257 div1
- Struct和Class的区别
- 09_Android中ContentProvider和Sqllite混合操作,一个项目调用另外一个项目的ContentProvider
- 09_Android中ContentProvider和Sqllite混合操作,一个项目调用另外一个项目的ContentProvider
- 多线程互斥方法
- 关于 JAR 您不知道的 5 件事
- Leecode Gas Station
- mongodb 学习笔记 06 -- mongod配置文件
- Java 运行时监控,第 3 部分: 监控应用程序生态系统的性能与可用性
- javascript 函数及作用域总结介绍
- Java 运行时监控,第 2 部分: 编译后插装和性能监控
- [Swust OJ 403]--集合删数
- 树莓派上的立体视觉和深度知觉
- Java 运行时监控,第 1 部分: Java 系统运行时性能和可用性监控
- 安卓恶意代码分析
- MVC 从后台页面 取前台页面传递过来的值的几种取法