开源中国-android客户端源代码阅读1
16lz
2021-01-26
项目结构如图:
包的分类很明确,看名字就知道意思:
net.oschina.app下面的AppStart类是程序的启动页面
应用程序启动类:显示欢迎界面并跳转到主界面
final View view = View.inflate(this, R.layout.start, null);setContentView(view); //渐变展示启动屏AlphaAnimation aa = new AlphaAnimation(0.3f,1.0f);aa.setDuration(2000);view.startAnimation(aa);aa.setAnimationListener(new AnimationListener(){@Overridepublic void onAnimationEnd(Animation arg0) {redirectTo();}@Overridepublic void onAnimationRepeat(Animation animation) {}@Overridepublic void onAnimationStart(Animation animation) {}});
24行的inflate,是找到启动也的xml配置文件
解释:setContentView()一旦调用, layout就会立刻显示UI;而inflate只会把Layout形成一个以view类实现成的对象,有需要时再用setContentView(view)显示出来。一般在activity中通过setContentView()将界面显示出来,但是如果在非activity中如何对控件布局设置操作了,这就需要LayoutInflater动态加载。
start.xml配置文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="bottom" android:background="@drawable/start_background"></LinearLayout>
在动画里启动..Main这个activity
/** * 跳转到... */ private void redirectTo(){ Intent intent = new Intent(this, Main.class); startActivity(intent); finish(); }
更多相关文章
- android显示大图片的一些技巧
- EditText属性大全详解
- android minui fb显示相关函数
- Android(安卓)推断当前的界面是否是桌面的方法
- Android布局管理器-使用FrameLayout帧布局管理器显示层叠的正方
- 在Android(安卓)Studio 中 activity的四中启动模式
- Android实现3秒钟自动关闭界面
- android两种启动Service方式的区别
- Android(安卓)按钮快速点击问题的解决方案!