框架布局FrameLayout
框架布局FrameLayout
一、简介

二、代码实例
结果图:


代码:
需要注意的代码:
imageView_play.setVisibility(View.INVISIBLE);
<FrameLayout
framelayoutfry2.MainActivity
package framelayoutfry2; import com.example.framelayoutfry2.R; import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView; public class MainActivity extends Activity implements OnClickListener{
private Button btn_play;//创建一个button对象
private Button btn_pause;//创建一个button对象
private ImageView imageView_play;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//父类操作
setContentView(R.layout.activity_main);//引入名为activity_main的界面
imageView_play=(ImageView) findViewById(R.id.imageView_play);
btn_play=(Button) findViewById(R.id.btn_play);
btn_pause=(Button) findViewById(R.id.btn_pause);
btn_play.setOnClickListener(this);
btn_pause.setOnClickListener(this); }
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btn_play:
imageView_play.setVisibility(View.INVISIBLE);
break;
case R.id.btn_pause:
imageView_play.setVisibility(View.VISIBLE);
break;
default:
break;
}
}
}
/Test_FrameLayout/res/layout/activity_main.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"
android:orientation="vertical" > 7 <FrameLayout
8 android:layout_width="match_parent"
9 android:layout_height="wrap_content"
10
11 >
12 <ImageView
13 android:layout_width="match_parent"
14 android:layout_height="250dp"
15 android:src="@drawable/frame_bg"
16 />
17
18 <ImageView
19 android:id="@+id/imageView_play"
20 android:layout_width="35dp"
21 android:layout_height="35dp"
22 android:src="@drawable/play"
23 android:layout_gravity="bottom"
24 android:layout_marginBottom="38dp"
25 />
26
27 </FrameLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:id="@+id/btn_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="播放"
android:layout_weight="1"
/> <Button
android:id="@+id/btn_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="暂停"
android:layout_weight="1"
/> </LinearLayout> </LinearLayout>
框架布局FrameLayout的更多相关文章
- .Net程序猿乐Android发展---(10)框架布局FrameLayout
帧布局FrameLayout中全部的控件都在界面的左上側,后绘制的空间会覆盖之前的控件.布局内控件以层叠方式显示,用在游戏开发方面可能多些. 1.层叠展示 以下这个样例 ...
- Android 框架布局 FrameLayout
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android=" ...
- android FragmentActivity+FragmentTabHost+Fragment框架布局
这周比较闲,计划系统的学习一下android开发,我本是一名IOS程序员,对手机开发还是有自己的一套思路的, 固这套思路用到我当前学android上了,先选择从Main页面的tabbar部分代码入手, ...
- Android用户界面设计:框架布局(转)
摘要:框架布局是Android开发者组织视图控件最简单和最有效的布局之一.通过本文,你将学到所有关于框架布局的知识,它们主要用来在屏幕上组织特别的或重叠的视图控件.使用得当的话,很多有趣的Androi ...
- Android笔记(九) Android中的布局——框架布局
框架布局没有任何定位方式,所有的控件都会摆放在布局的左上角. 代码示例: framelayout.xml <?xml version="1.0" encoding=" ...
- Android中帧布局-FrameLayout和网格布局-GridLayout
帧布局-FrameLayout 一.概念 帧布局中,容器为每个加入其中的空间创建一个空白的区域(成为一帧).每个空间占据一帧,这些帧会按gravity属性自动对齐. 帧布局的效果是将其中的所有空间叠加 ...
- Android 自学之帧布局 FrameLayout
帧布局(FrameLayout)直接继承了ViewGroup组件: 帧布局容器为每一个加入其中的组件都创建了一个空白的区域,这个区域我们称之为一帧,所有每个组件都占据一帧,这些都会根据gravity属 ...
- Flutter实战视频-移动电商-53.购物车_商品列表UI框架布局
53.购物车_商品列表UI框架布局 cart_page.dart 清空原来写的持久化的代码; 添加对应的引用,stless生成一个静态的类.建议始终静态的类,防止重复渲染 纠正个错误,上图的CartP ...
- Layui栅格系统与后台框架布局
一.栅格布局规则: 1. 采用 layui-row 来定义行,如:<div class="layui-row"></div> 2. 采用类似 layui-c ...
随机推荐
- Making training mini-batches
Here is where we'll make our mini-batches for training. Remember that we want our batches to be mult ...
- POJ 1423 Greatest Common Increasing Subsequence【裸LCIS】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1423 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- SpringMVC 之数据转换和国际化
1. 数据绑定流程 SpringMVC 主框架将 ServletRequest 对象及目标方法的入参实例传递给 WebDataBinderFactory 实例,以创建 DataBinder 实例对象; ...
- tpot从elastic search拉攻击数据之三 用于拉取的java程序
package download; import org.json.JSONArray; import java.io.*; import java.net.URL; import java.net. ...
- python单线程解决并发
1.单线程解决并发 方式一 import socket import select # 百度创建连接:非阻塞 client1 = socket.socket() client1.setblocking ...
- 【我的Android进阶之旅】如何在浏览器上使用Octotree插件树形地展示Github项目代码?
前言 最近有个同事看到我打开Github项目时,浏览器上的展示效果是树形的,于是他问我这个是什么浏览器插件,我告诉他是Octotree插件.现在我就来介绍介绍这款Octotree插件. 效果对比 1. ...
- 解决[[NSFileManager defaultManager] contentsOfDirectoryAtPath 方法获取不到数据的bug
在说这个问题之前,必须先解释一下,我们在引入project的时候,xcode会给我们3个选项 1.Copy items if needed 主要是说明,是否要将文件复制到project所在文件夹. 假 ...
- hibernate自动建表之engine设置
1.MYSQL的数据库引擎中,只有InnoDB和BDB(Berkley DB )包括了对事务处理和外键的支持.如果数据引擎建为MyISAM则rollback无效. 2.而hibernate自动建表的时 ...
- hadoop namenode
存储文件系统元数据,例如:文件目录结构,不同文件的分块情况,每块存储在那个节点,权限等 这些元数据全部存储在内存中,所以,namenode要求内存比较大 hdfs在存文件的时候会按照块存储,每一块默认 ...
- PHP获取客户端的IP
function getClientIP(){ global $ip; if (getenv("HTTP_CLIENT_IP")) $ip = geten ...