Android仿新浪微博弹出界面动画,Android仿新浪微博启动界面或登陆界面(1)
本文为大家分享了Android模仿新浪微博启动界面&登陆界面的具体实现代码,供大家参考,具体内容如下
启动界面
主要有两个功能:
1.加载启动动画
2.判断网络,有者直接进入登陆界面,否则去设置网络
代码较简单,主要采用AlphaAnimation()方法和动画监听器,使一张图片产生渐变动画。在动画启动的时候判断网络,动画结束时完成判断并进入登陆界面。
/**
* Created by D&LL on 2016/5/25.
* 初始页面加载界面
*/
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
ImageView splashimage = (ImageView) findViewById(R.id.splashimage);
//透明度渐变动画
AlphaAnimation animation = new AlphaAnimation(0.1f, 1.0f);
//设置动画时长
animation.setDuration(3000);
//将组件和动画进行关联
splashimage.setAnimation(animation);
animation.setAnimationListener(new Animation.AnimationListener() {
//动画启动执行
@Override
public void onAnimationStart(Animation animation) {
Toast.makeText(SplashActivity.this, "欢迎使用DeMon制作微博", Toast.LENGTH_LONG).show();
//检查并网络的方法
Tools.checkNetWork(SplashActivity.this);
}
//动画结束执行
@Override
public void onAnimationEnd(Animation animation) {
Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
//动画重复执行
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
使用ConnectivityManager获取系统的连接服务,然后获取代表联网状态的NetWorkInfo对象,获取网络的连接情况,如果没有网络则生成一个AlertDialog引导进行网络设置。该方法位于Tools.java中。
/**
* 设置网络
*
* @param context
*/
public static void checkNetWork(final SplashActivity context) {
if (!NetWorkStatus(context)) {
TextView msg = new TextView(context);
msg.setText("请设置网络!");
AlertDialog.Builder b = new AlertDialog.Builder(context).
setIcon(R.drawable.notnet)
.setTitle("没有可用的网络")
.setMessage("是否对网络进行设置?");
b.setPositiveButton("是", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//跳转到设置网络界面
context.startActivity(new Intent(Settings.ACTION_SETTINGS));
}
}).setNeutralButton("否", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
context.finish();
}
}).create().show();
}
}
/**
* 判断网络状态
*/
public static boolean NetWorkStatus(Context context) {
//获取系统的连接服务
ConnectivityManager connect = (ConnectivityManager) context.getSystemService(Context
.CONNECTIVITY_SERVICE);
if (connect == null) {
return false;
} else {
// 获取代表联网状态的NetWorkInfo对象,获取网络的连接情况
NetworkInfo[] infos = connect.getAllNetworkInfo();
if (infos != null) {
for (NetworkInfo network : infos) {
if (network.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
SplashActivity的布局文件splash.xml
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/splashimage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/splashimage"/>
style="@android:style/Widget.ProgressBar.Inverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_gravity="center"
android:layout_marginBottom="64dp"
android:layout_marginStart="130dp">
登陆界面
此界面只有几个按钮,故合在一条博客里。
微博按钮触发进入到到授权界面
public class LoginActivity extends Activity {
private Button sinalogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
sinalogin = (Button) findViewById(R.id.sinalogin);
sinalogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this, OAuthActivity.class);
startActivity(intent);
LoginActivity.this.finish();
}
});
}
}
布局文件login.xml两个自定义样式的EditText,一个普通按钮(此处纯粹摆设)。只有微博登陆按钮有用。
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="40dip"
android:background="@drawable/bg_edittext"
android:ems="10"
android:inputType="textPersonName">
android:id="@+id/passworld"
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_marginTop="20dip"
android:background="@drawable/bg_edittext"
android:ems="10"
android:inputType="textPassword"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:id="@+id/login"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:layout_weight="1"
android:text="登录"/>
android:id="@+id/sinalogin"
android:layout_width="200dp"
android:layout_height="38dp"
android:layout_marginTop="20dip"
android:layout_weight="1"
android:background="@drawable/weibologin"/>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
Android仿新浪微博弹出界面动画,Android仿新浪微博启动界面或登陆界面(1)相关推荐
- android 日历翻页动画,Android 仿日历翻页、仿htc时钟翻页、数字翻页切换效果
废话不多说,效果图: 自定义控件找自网络,使用相对简单,具体还没有来得及深入研究,只是先用笨方法大概实现了想要的效果,后续有空会仔细研究再更新文章, 本demo切换方法是用的笨方法,也就是由新数字和旧 ...
- android 图片预览动画,Android实现仿Windows7图片预览窗格效果
本实例将显示类似于windows7提供的图片预览窗格效果,单击任意一张图片,可以在右侧显示该图片的预览效果. 效果如图所示: 具体实现方法: res/layout/main.xml: android: ...
- android抖音loading动画,高仿抖音视频加载动画
动画效果: loadingView.gif 由于GIF图压缩的问题看起来不好看,在真机和模拟器上看是没有问题的 这个动画实现起来还是很容易的,原理其实就是利用CGAffineTransformScal ...
- android 仿qq录音动画,Android实现QQ点赞效果动画 Android动画
版权声明:本文为代码部落原创文章,转载请注明出处. 前言 点赞是现在社交app中比较常用的功能,一个小小的点赞按钮如果能加上一些有趣动画,一来告诉用户你已经点了赞(这是对一些手残党极大的福音),二来人 ...
- android加载转圈动画,android 围绕中心旋转动画
本文主要介绍Android中如何使用rotate实现图片不停旋转的效果.Android 平台提供了两类动画,一类是 Tween 动画,即通过对场景里的对象不断做图像变换(平移.缩放.旋转)产生动画效果 ...
- android 一分钟倒计时动画,Android View篇之启动页倒计时动画的实现
Hello,小伙伴们大家好,今天介绍一个很简单的倒计时动画,仿酷狗音乐的启动页倒计时效果,也是大多数APP在用的一个动画,来看看效果图: 在这里插入图片描述 整体的思路就是用一个平滑的帧动画来画圆弧就 ...
- android 向左滑动动画,Android中的滑动动画
这是问题所在. 我想从左到右滑动(在下面的代码中从右到左--) 所以请帮我动画(XML动画与此相反)-- (当前任务在按钮单击时正确运行-) 这是源- public class MainActivit ...
- android 那几种动画,Android 动画实现几种方案
Android 动画实现几种方案 在 Android 的 FrameWork 中,为我们提供三种动画的实现方式:逐帧(Frame)动画.视图/补间动画(View Animation)和属性动画(Pro ...
- android imageview图片旋转动画,Android 安卓动画 属性动画 - 旋转动画
引入 属性动画的出现,弥补了补间动画的不足之处,补间动画,只是改变了表面上的东西,但是其中属性并未改变,而属性动画相反,改变了表面上的东西,并且也更改了其属性. 类:ObjectAnimator 用于 ...
最新文章
- 移远NB-IOT BC28模块模组简介和实际应用方向详解
- 企业主要财务指标有哪些
- qr分解求线性方程组_计算方法/数值分析第三章 线性方程组的数值解法
- 简明Python教程学习笔记_3_模块
- VC 忽略警告的方法
- javascript 中的 call
- JS中获取地址栏中的参数
- Centos6.5 源码安装MySql5.6.33
- Etherpad配置及管理功能
- python实现topsis法
- 开关三极管的导通和截止条件
- 早起的奇迹,梦醒后成为梦想的自己!
- 【论文笔记】—低照度图像增强—Supervised—RetinexNet—2018-BMVC
- window下PC版 charles小程序抓包
- 平安保险IT员工收入揭秘
- 给 Java 程序猿们推荐一些值得一看的好书
- 安卓AS一键发布到蒲公英
- 展望下未来的计算机400字,展望未来的作文400字
- 五分之二用计算机怎么按,2015年计算机等级考试上机应试技巧
- android canvas画渐变背景,View绘制系列(13)-Canvas渐变属性绘制