Android 手機衛士--home介面布局,android--home

來源:互聯網
上載者:User

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介面,首先實現的是標題列,效果如下:

代碼如下:

  <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" />

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.