1. XML Layouts
首先在目录 “res/layout/” 下创建两个XML layout文件 :
res/layout/activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:id="@+id/text_view"/>
</RelativeLayout>
res/layout/activity_other.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" >
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/second_page"/>
</LinearLayout>
2. Activities
创建两个activity类
MainActivity.java –> activity_main.xml
OtherActivity.java –> activity_other.xml
切换关键代码
Intent intent = new Intent(MainActivity.this, OtherActivity.class);
startActivity(intent);
MainActivity.java
package com.lance.changescreen;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView mTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextView = (TextView)findViewById(R.id.text_view);
addTextViewListener();
}
/**
* 点击mTextView, 切换到另外一个屏幕
*/
private void addTextViewListener() {
mTextView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, OtherActivity.class);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
OtherActivity.java
package com.lance.changescreen;
import android.app.Activity;
import android.os.Bundle;
public class OtherActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_other);
}
}
3. AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lance.changescreen"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.lance.changescreen.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- add OtherActivity-->
<activity android:label="@string/app_name"
android:name="com.lance.changescreen.OtherActivity"/>
</application>
</manifest>
分享到:
相关推荐
支持1.6的滑动切屏 使用viewpager
Activity切屏动画 11种特效源代码 亲测能用 很绚 如过不能用作者就不是人!!请放心下载!
实现的效果就是两个activity进行切换时候的动画,其实了解的话其实都非常简单,最近MIUI更新版本之后,现在MIUI的启动界面也采用了有底部向上部平移的动画。其中用到了ButterKnife注解,代码跟全部手写要简洁一些。 ...
android中手机切屏是activity生命周期的变化[收集].pdf
切屏广告切屏广告切屏广告切屏广告切屏广告切屏广告
ViewPager+自定义ViewGroup来实现同时支持上下左右切屏。ViewPager实现左右切屏,ViewGroup负责上下切屏。
Android 仿Q空间 滑动切屏实例 ScrollerView 实现 滑动切屏动画 各个页面 控件事件监听 完整代码!支持2.1以上版本
一个切屏后需要退出两次的activity
LCD 分屏 切屏 Tearing effect Hx8357
谷歌或者浏览器破无限切屏方法,能在监测切屏的网页中破解切屏限制,达到无限次数切屏。比如在线考试中无限制切屏
切屏实例3个切屏实例3个切屏实例3个切屏实例3个切屏实例3个切屏实例3个
切屏 和控制按钮
vs编写 一键切屏 方面试用 真实代码 可供参考
快速切屏软件
在发布线上考试的过程中,会出现学生切屏的情况。那么如何找到切屏检测功能呢,本教程介绍了线上考试中如何设置切屏检测监考模式的操作方法。
切屏及仿小米视频滚动客户端
如果看中一个网页的页面效果,下载有了他,就方便切图保存了
android 左右滑动 焦点穿透特效 模仿酷狗特效 demo 浅近深入 提高自己的自动以View能力 注释很全 也可参考做开发
仿IPHONE切屏特效 JQUERY 源码