FrameLayout

 

 
 

 

package layout.app;
import android.app.Activity;
import android.os.Bundle;
import android.vie.View;
import android.widget.ImageView;
public class FrameLayoutActivity extends Activity{
private ImageView iv;
public void onCreate(Bundle savedInstanceState){
super.onCreate(R.layout.test_frame);
iv=(ImageView)findViewById(R,id,iv);
}
public void play(View view){
iv.setVisibility(view.INVISIBLE);
}
public void play(View view){
iv.setVisibility(view.VISIBLE);
}
}
<?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"
<ImageView
android:visibility="visible"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android src="@drawable/movie"/*在res文件下的drawable文件里拷贝一个电影画面*/
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_contentt"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_contentt"
android:onClick="pause"
android:text="暂停"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_contentt"
android:onClick="play"
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="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/play"
    android:visibility="visible"
    />
</LinearLayout>
</FrameLayout>

 运行为jandroid application得到


FrameLayoutdi
点击暂停按钮得到如下界面


FrameLayout
 关键是借助了Button按钮的android:OnClick属性,然后在src类里面出现对应的方法 

你可能感兴趣的:(FrameLayout)