• 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界面,首先实现的是标题栏,效果如下:

    代码如下:

      <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" />
  • 相关阅读:
    wpf 用c#代码给img指定uri
    c 指针作为出参
    wpf获得系统毫秒数
    绑定元素的长宽(Canvas的子类自动伸展)
    PB与COM之关于创建COM,MTS, and COM+组件(1)
    ASA破解密码
    遭遇奸商(显卡篇)
    “启动Word时提示出错,只能用安全模式才能打开”的解决方法
    PowerSocket对象与HostName
    制做集成SATA驱动的XP安装盘
  • 原文地址:https://www.cnblogs.com/wuyudong/p/5906385.html
Copyright © 2020-2023  润新知