Open source in the National security Android Client Source Learning (a) gradient start interface

Source: Internet
Author: User

Open source in the National security Android Client Source Learning (a)

Ready to learn the development of Android, see online people recommend open source in the source of the national security Zhuo client, said that contains most of the technology, so ready to study research. This series of blogs is launched to record the learning process. Because is in the study, the experience is insufficient, inside certainly has many wrong place, looks everybody to correct.

Download the source package here, the development environment for Linux under the eclipse, after importing the source code may appear Android.webkit.CacheManager can not find errors, because this class in the 4.0 version of the SDK was deleted, Just download the 4.0 version of the SDK for use. As Google is wall, using the SDK Manager may not be able to download, you can download the 4.0 SDK directly on the Internet, the name of the folder to Android-15, placed in the ANDROID-SDK platforms directory.

The first is the gradient start screen.

Navigate to the program entry,/oschina-android-app/src/net/oschina/app/appstart.java, AppStart as the startup class, onCreate method for the Ingress method,

final View view = View.inflate(this, R.layout.start, null); //由layout文件夹下的start.xml文件定义启动界面视图setContentView(view);  // 设置activity显示的视图

The contents of the Start.xml file are as follows:

<?xml version= "1.0" encoding= "Utf-8"?><linearlayout xmlns:android="Http://schemas.android.com/apk/res/android"  Android:id="@+id/app_start_view"android:orientation="vertical"android: Layout_width="Fill_parent"android:layout_height="Fill_parent"android: Gravity="Bottom"android:background="@drawable/start_background">                         The gradient uses the picture, but here the Start_background is an XML file to control the picture more precisely</linearlayout>

Start_background.xml content is as follows

<?xml version="1.0" encoding="utf-8"?><bitmap xmlns:android="http://schemas.android.com/apk/res/android"    android:src="@drawable/welcome" // 启动图片, welcome.png    android:scaleType="fitStart"/> // 缩放类型

Using AlphaAnimatio classes to achieve the gradient effect of the start-up interface

Alphaanimation AA =NewAlphaanimation (0.3F1.0f);//Gradient Transparency rangeAa.setduration ( -);//DurationView.startanimation (AA);//Start gradientAa.setanimationlistener (NewAnimationlistener ()//Listen to events, set gradient start, repeat, end of processing{@Override         Public void Onanimationend(Animation arg0) {Redirectto ();//Enter the main interface after the gradient finishes}@Override         Public void onanimationrepeat(Animation Animation) {}@Override         Public void Onanimationstart(Animation Animation) {}    });

The function below is to open redirectTo a new activity that opens the main interface and ends the current activity

privatevoidredirectTo(){                new Intent(this// Main 是一个继承了Activity的类        // 在新的activity中打开主界面        // 结束当前activity }

The other two functions in this check class getTime are not important and skip over.

Tips: After modifying the image resource on the splash screen, you should clean up the project cache in Eclipse's Project-clean, or you may not be able to display the modified interface immediately.

Open source in the National security Android Client Source Learning (a) gradient start interface

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.