[原创]android framelayout&n…
来源:互联网 发布:知乎必读书单 编辑:程序博客网 时间:2024/06/06 02:31
这个类是我实际做android时候做activity内的浮动层效果时封装的类
如果一个界面有多个浮动层可以简单复制这个类快速做出多个浮动层来
public class PlayerHeader extends FrameLayout {
private static final String LOG_TAG =MainActivity.class.getName();
public PlayerHeader(Context context) {
super(context);
mContext = context;
}
public PlayerHeader(Context context, AttributeSet attrs){
super(context, attrs);
headerRoot = null;
mContext = context;
}
public PlayerHeader(Context context, AttributeSet attrs, intdefStyle) {
super(context, attrs, defStyle);
}
// 这里只调用一次,使用这个函数创建一个布局到framelayout
public void init(ViewGroup anchorView, VideoView videoview){
mAnchor = anchorView;
// init header -----------------
LayoutInflater inflate = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//新建的层放在framelayout顶部
FrameLayout.LayoutParams tlp1 = newFrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP);
// init header
headerRoot = inflate.inflate(R.layout.media_controler_header,null);
//这个只是示范代码,在这里记录所有控件的句柄
bTitle = (TextView)headerRoot.findViewById(R.id.video_title);
bIcon = (ImageView)headerRoot.findViewById(R.id.channel_icon);
mAnchor.addView(headerRoot, tlp1);
hide();
}
// 控制板显示/
public void show() {
headerRoot.setVisibility(VISIBLE);
mShowing = true;
}
public void hide() {
headerRoot.setVisibility(INVISIBLE);
mShowing = false;
}
}
使用方法
playerHeader= new PlayerHeader (this);
//找到要添加浮动层的framelayout
playerHeader.init((FrameLayout) findViewById(R.id.ff),player);
playerHeader.show()//显示
playerHeader.hide()//显示
阅读全文
0 0
- [原创]android framelayout&n…
- [原创]android resource&nbsp…
- 【原创】 linux mysql&n…
- 【原创】Linux-Ubuntu 12.4&n…
- 【原创】linux ubuntu12.04&n…
- 【原创】linux ubuntu12.04&n…
- 【原创】linux ubuntu12.04&n…
- 【原创】linux ubuntu12.04&n…
- 【原创】Linux 终端/Screen&n…
- 【原创】SSH/Python Error:&n…
- 处理Android SQLite -&n…
- 【原创】please install&nbsp…
- 【原创】 linux Python&…
- 【原创】sudo: -User-&…
- 【原创】Python PyQuery&nbsp…
- 【转】彻底解决Android SDK&n…
- Note 452067.1 &n…
- jcop external&n…
- android 视频播放器的seekbar…
- proftpd 保证上传文件完整
- PHP5.4 正则-只允许中文英文…
- android dpi模式与px di…
- caffe学习笔记4:激活层及其参数
- [原创]android framelayout&n…
- mysql 主从库更新延迟,通过o…
- 【翻译整理】mysql innodb&nb…
- fastdfs php v5.01&nbsp…
- redis php 队列开发
- 机器学习&深度学习近三年被引最多论文 Top 20,图像识别、GAN等(附下载)
- 使用redis做排行服务
- 基础mysql binlog监视器的数…
- oracle中有分隔符的列转成多行