RelativeLayout的一个特性
来源:互联网 发布:c语言的科学和艺术 pdf 编辑:程序博客网 时间:2024/06/05 03:30
实现效果为将ic_launcher压在上面图片(图片大小不固定)的最下面
**
>下面代码有误请直接查看评论,感谢“魏成林 ”的指正!!!
**
xml代码
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/bannerImg" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:src="@drawable/img" /> <ImageView android:id="@+id/activity_entrance" android:layout_width="60dp" android:layout_alignParentBottom="true" android:layout_height="60dp" android:layout_gravity="right" android:src="@mipmap/ic_launcher" /> </RelativeLayout></LinearLayout>
但是上面xml文件实现的效果图如下
可以看到使用 android:layout_alignParentBottom=”true”属性的时候高度是按照match_parent计算的
解决办法在RelativeLayout外面嵌套一层ScrollView
xml代码
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:fillViewport="true"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/bannerImg" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:src="@drawable/img" /> <ImageView android:id="@+id/activity_entrance" android:layout_width="60dp" android:layout_height="60dp" android:layout_alignParentBottom="true" android:layout_gravity="right" android:src="@mipmap/ic_launcher" /> </RelativeLayout> </ScrollView></LinearLayout>
我只是记录了一下踩到坑的解决办法,但是为什么不知道原因,哪位大神如果知道原因,请在下面留言,感谢!!!
阅读全文
0 0
- RelativeLayout的一个特性
- Android RelativeLayout一个靠左靠右靠中间的listview
- 关于RelativeLayout的一个奇怪问题
- Android RelativeLayout padding 的一个坑?
- Array的一个特性
- 自定义一个relativelayout
- Android官方文档的一个RelativeLayout的案例
- 一个继承自RelativeLayout的输入法监听布局
- 服务器端表单的一个特性
- Attribute:特性的一个例子
- springmvc的一个跳转特性
- 一个软件工程产品的特性
- 一个demo学习完RelativeLayout
- RelativeLayout.ALIGN_BOTTOM和RelativeLayout.ALIGN_PARENT_BOTTOM的区别
- RelativeLayout 的参数意义
- RelativeLayout 重要的属性
- Relativelayout的一些属性
- RelativeLayout的布局
- SmartRefreshLayout集成笔记,实现下拉刷新上拉加载更多。
- 仿微软写了一个win32 计算器小程序
- SQL整理
- [RK3288][Android6.0] 调试笔记 --- 查看Activity对应调用的进程
- Party Games UVA
- RelativeLayout的一个特性
- slidingmenu侧拉页面
- CAN 、I2S、I2C、SPI 、SSP总线简介
- Integer 类型的变量,编译器不会给你默认值,不赋值会报错
- 代码详解のTreeMap实现原理
- 定时器
- uploadfile
- C#中ArrayList类的使用方法
- python二叉树 知识点概括