"Side do project side learn Android" mobile Security defender 01:splash Interface UI

Source: Internet
Author: User

Mobile Security defender Project is to follow the black horse to do the video.

Splash is splash, splash meaning, mainly used to complete a product logo display, during the period can:

    1. Background completion of database initialization operations
    2. Networked access server to get the latest server information (upgrade tips)
    3. Different dates show different logos, judging the current system time, the material is generally downloaded from the server.
    4. Judging time, displaying different loading pages depending on the time
Layout file: Splash.xml
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:layout_width=" match_parent "    android:layout_height=" Match_parent "    android: background= "@drawable/logo2"    android:gravity= "center_horizontal"    android:orientation=    "vertical" Android:id= "@+id/ll_splash_main"    >    <textview        android:layout_margintop= "320dip"        android: Id= "@+id/tv_splash_version"        android:layout_width= "wrap_content"        android:layout_height= "Wrap_content"        android:textcolor= "#FFff5f00"        android:textsize= "20sp"        android:text= "version number"          />       < ProgressBar        android:layout_width= "wrap_content"        android:layout_height= "Wrap_content"        android: layout_margintop= "20dip"        /></linearlayout>

Activity:splashactivity
Package Com.liuhao.mobilesafe.ui;import Com.liuhao.mobilesafe.r;import Android.os.bundle;import Android.app.activity;import Android.content.pm.packageinfo;import Android.content.pm.packagemanager;import Android.view.menu;import Android.view.window;import Android.view.windowmanager;import Android.view.animation.alphaanimation;import Android.widget.linearlayout;import Android.widget.TextView;public    Class Splashactivity extends Activity {private TextView tv_splash_version;private linearlayout Ll_splash_main;                @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);                Remove title bar requestwindowfeature (Window.feature_no_title);                Setcontentview (R.layout.splash);        Tv_splash_version = (TextView) This.findviewbyid (r.id.tv_splash_version);                Ll_splash_main = (linearlayout) This.findviewbyid (R.id.ll_splash_main);        String Versiontext = GetVersion (); Tv_splash_version.settext (vErsiontext);         /* Alphaanimation class: Transparency Change Animation class * Alphaanimation class is an animation class for transparency changes in Android systems that controls the transparency of a View object, which inherits from the animation class.         * Many methods in the Alphaanimation class are consistent with the animation class, and the most common method in this class is the Alphaanimation construction method. * Public alphaanimation (float fromalpha, float toalpha) parameter description Fromalpha: Transparency at start time, value range 0~1.         Toalpha: The transparency of the end time, the value range 0~1.        */alphaanimation AA = new Alphaanimation (0.0f, 1.0f); Aa.setduration (2000); Animation class method, set Duration ll_splash_main.startanimation (AA); Set the animation//complete full-screen display of the form GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WINDOWMANAGER.L    Ayoutparams.flag_fullscreen); } @Override Public boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu, this adds items to the Actio        n Bar if it is present.        Getmenuinflater (). Inflate (R.menu.splash, menu);    return true; /** * Gets the version number of the current program * @return */private String getversion () {//Gets an instance of Packagemanager,The global package information can then be obtained Packagemanager manager = Getpackagemanager (); try {//Retrieve overall information about a application package, that's installed on the system. PackageInfo info = manager.getpackageinfo (getpackagename (), 0);//The version name of this package, as specified by the &L t;manifest> tag ' s versionname attribute.return info.versionname;}        catch (Exception e) {e.printstacktrace (); return "version number Unknown";} }} 
Relevant knowledge points:

In developing programs that often require full-screen display of software, custom titles (using controls such as buttons) and other requirements, today this is how to control the form display of Android applications.

First of all, an important approach is requestwindowfeature (Featrueid), which is the ability to enable the extended nature of the form. Parameters are constants defined in the window class.

One, enumeration constants

1.default_features: System default state, generally do not need to specify

2.feature_context_menu: Enable ContextMenu, which is enabled by default, generally does not need to specify

3.feature_custom_title: Custom caption. You must specify when you want to customize the caption. such as: When the caption is a button

4.feature_indeterminate_progress: Indeterminate Progress

5.feature_left_icon: Icon to the left of the title bar

6.feature_no_title: Untitled

7.feature_options_panel: Enable the Options Panel feature, which is enabled by default.

8.feature_progress: Progress indicator function

9.feature_right_icon: Icon to the right of the title bar


Default:default_features

Progress:feature_progress: Progress indicator function

No title:feature_no_title: Untitled


Lefticon:feature_left_icon: Icon to the left of the title bar


Fullscreen:

Indeterminate_progress:feature_indeterminate_progress: Indeterminate Progress

Customtitle:feature_custom_title: Custom caption.

The Alphaanimation class is an animated class of transparency changes in an Android system that controls the transparency of a view object that inherits from the animation class. Many of the methods in the Alphaanimation class are consistent with the animation class, and the most common method in this class is the Alphaanimation construction method.

"Basic Syntax" public alphaanimation (float fromalpha, float toalpha)

Parameter description

Fromalpha: The transparency of the start time, the value range 0~1.

Toalpha: The transparency of the end time, the value range 0~1.

Run

Operating effect:

"Side do project side learn Android" mobile Security defender 01:splash Interface UI

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.