Android下实现控件的叠加显示
来源:互联网 发布:metasploit 445端口 编辑:程序博客网 时间:2024/06/05 04:39
在做手机软件时,经常会遇到空间叠加显示的问题,比如在一个图片的buttom|center上添加一个名字或者是加上log图片,这样的图片当然可以通过PS等软件进行处理之后直接setSource给ImageView,但是这种方式只能处理静态的事务。如果需要动态的在某些图片上添加其他的物件的话,就需要用到我们今天介绍的FrameLayout。
FrameLayout没有标准的中文翻译,但是就功能来看,“单帧布局”貌似要比“框架布局”更贴切一些。在FrameLayout上面添加控件,就好像是向一张画布上添加一张一张的贴片,后面的控件会覆盖在之前的控件之上。如果后面的控件比较小,就可以很容易的实现上面所述的控件叠加的需求了。至于怎么使用,在网上应该会有比较多的文章介绍。这里就不在赘述。
可能遇到的问题:
1、在图片A的buttom|center位置添加图片B。首先在FrameLayout上面加上图片A,然后再添加图片B。同时需要设置图片B的margin以在合适的位置。但是在测试过程中发现,如果直接在FrameLayout直接设置B的margin,效果不会显示。解决这个问题的一个比较简单的办法就可以在图片B和FrameLayout之间叠加一层Layout,比如LinearLayout等。这样就可以实现上述需求了。
<FrameLayout android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_marginTop="5dip" android:orientation="vertical" > <Gallery android:id="@+id/pro_detail_gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="0dp" /> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" android:layout_marginBottom="20dip" android:layout_marginLeft="50dip" android:layout_marginRight="50dip" android:layout_gravity="bottom" ><TextView android:id="@+id/pro_priceTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textColor="#000" /> <Button android:id="@+id/buy_btn" android:layout_width="wrap_content"android:layout_height="wrap_content" android:gravity="center" android:layout_alignParentRight="true" android:text="购入囊中" android:textColor="#fff" android:background="@drawable/buy" /> </RelativeLayout> </FrameLayout>
- Android下实现控件的叠加显示
- android 文字叠加显示在图片之上控件的实现 -- 充分利用TextView
- android 文字叠加显示在图片之上控件的实现 -- 充分利用TextView
- RelativeLayout 下的控件叠加
- Android Toast显示叠加的问题
- android RelativeLayout控件或view实现叠加效果
- Android两个SurfaceView叠加显示
- [读书笔记] Android Toast 显示时间叠加问题的探讨
- Android代码实现控件按下显示底色效果
- CityEngine下如何更好的实现影像与地形叠加
- CityEngine下如何更好的实现影像与地形叠加
- 图像叠加及透明度的调整在matlab下实现
- Android的图片叠加
- android下view的画布和Bitmap及叠加覆盖
- android 图片叠加效果实现
- 歌词显示控件的实现下——自定义View
- ArcGis下的叠加分析
- 实现DIV的叠加使用
- 关于2.6.32在创建bus总线时的bus_id和.init_name的问题
- 。。。。。
- 安装完 Windows7 之后所需的瘦身清理工作
- c#中 uint--byte[]--char[]--string相互转换汇总
- UML类图与类的关系详解
- Android下实现控件的叠加显示
- [web开发实战手册(6.0.0)]——web前端开发规范文档
- console tty 串口
- 黑马程序员_IO流技术总结
- S7-200西门子PLC自由串口通信
- arm板 释放ttyS0作为通信串口(关闭调试串口)
- POJ1128 Frame Stacking [拓扑排序+dfs]
- RSA算法加解密(JAVA)
- 完全退出程序(Android)