Android 手机卫士--home界面布局

【Android 手机卫士--home界面布局】将相本无种,男儿当自强。这篇文章主要讲述Android 手机卫士--home界面布局相关的知识,希望能为你提供帮助。
本文实现当从splash界面进入hone界面的时候,产生一种渐进淡入的动画效果,在onCreate中调用一个方法initAnimation(),代码如下:

/** * 添加淡入的动画效果 */ private void initAnimation() { AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1); alphaAnimation.setDuration(3000); rl_root.startAnimation(alphaAnimation); }

其中rl_root在类中定义
private RelativeLayout rl_root;
其中rl_root为splash界面相对布局的id:android:id="@+id/rl_root"
本文地址:http://www.cnblogs.com/wuyudong/p/5906385.html,转载请注明源地址。
于是在初始化UI方法中添加相应的代码
/** * 初始化UI方法 alt+shift+j */ private void initUI() { tv_version_name = (TextView) findViewById(R.id.tv_version_name); rl_root = (RelativeLayout) findViewById(R.id.rl_root); }

这样就实现了splash界面的淡入效果
接下来逐步实现home界面,首先实现的是标题栏,效果如下:
Android 手机卫士--home界面布局

文章图片

代码如下:
< TextView android:text="功能列表" android:gravity="center" android:textSize="20sp" android:textColor="#000" android:padding="10dp" android:background="#0f0" android:layout_width="match_parent" android:layout_height="wrap_content" />

但是由于标题栏的样式很常用,所有将其写成样式封装便于以后直接调用,于是在style.xml文件中添加下面的代码:
< style name="TitleStyle"> < item name="android:gravity"> center< /item> < item name="android:textSize"> 20sp< /item> < item name="android:textColor"> #000< /item> < item name="android:padding"> 10dp< /item> < item name="android:background"> #0f0< /item> < item name="android:layout_width"> match_parent< /item> < item name="android:layout_height"> wrap_content< /item> < /style>

这样在activity_home.xml中只需要进行简单的调用:
< TextView android:text="功能列表" style="@style/TitleStyle" />

 

    推荐阅读