**播放界面**
**暂停界面**
布局界面 layout/frame.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:visibility="visible" //可见
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" //表示控件内所有部件整体的位置,注意是相对于控件本身,限定它里面的内容要垂直居中显示。
android:text="我是视频,我正在播放视频"
/>
<LinearLayout //线性布局
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >//android:orientation="vertical":意思是垂直布局。水平布局的话是horizontal
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="play" //点击事件第四种写法
android:text="播放"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="pause" //点击事件第四种写法
android:text="暂停"
/>
</LinearLayout>
<LinearLayout //线性布局
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"> //表示控件内所有部件整体的位置,注意是相对于控件本身,限定它里面的内容要垂直居中显示。
<ImageView
android:id="@+id/iv"
android:layout_width="68dp"
android:layout_height="68dp"
android:src="@drawable/icon_9" //src代表source,@代表引用,意思就是使用drawable文件夹中的icon_9这个图片作为你当前使用的图片。
android:visibility="invisible" /> //不可见
</LinearLayout>
</FrameLayout>
MainActivity.java
package com.example.ppp;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends ActionBarActivity {
private ImageView iv; //定义为内部成员
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.frame); //Activity采用R.layout下的frame.xml布局文件进行布局
iv = (ImageView) findViewById(R.id.iv);
}
public void play(View view){ //第四种点击事件
iv.setVisibility(view.INVISIBLE);
}
public void pause(View view){ //第四种点击事件
iv.setVisibility(view.VISIBLE);
}
}