Android Development Tips (3)

Source: Internet
Author: User
Tags transparent color

Welcome to follow my GitHub and follow my csdn.

I'll introduce some interesting little points about Android. This article is the third, the rest of the first article, the second article.

imagemogr2/auto-orient/strip%7cimageview2/2/w/1240 "alt=" Android "title=" ">

1. Uiautomatorviewer

Self-motivated test is the trend of Android testing, stability \ Reuse, the most frequently used tool is espresso.
Use Uiautomatorviewer to get the ID of the resource,
Location/android-sdk/tools/uiautomatorviewer, click to use.

2. GitHub tags

Web site, for example:

3. Interesting changes to the SVG library

Address, load images in SVG format, change color properties.

4. The JSON plug-in for requests and builds

Jsononlineviewer, network request plugin, get JSON data, location view->jsonviewer.
Gsonformat, based on the JSON self-generated class plug-in, command+n inside.

Attached to a plug-in, any other.

5. How to set the Interceptor of RETROFIT2+OKHTTP3

Retrofit upgrade to the BETA3 version number, using the latest OKHTTP3, the way the interceptor is set up has changed.

Old version

Okhttpclient client = new Okhttpclient (). Builder();Httplogginginterceptor logginginterceptor = new Httplogginginterceptor ();Logginginterceptor. SetLevel(Httplogginginterceptor. level. BASIC);Marvelsigninginterceptor signinginterceptor = new Marvelsigninginterceptor (buildconfig. MARVEL_public_key, Buildconfig. MARVEL_private_key);Client. Interceptors(). Add(Signinginterceptor);Client. Interceptors(). Add(Logginginterceptor);

Replace, new

Httplogginginterceptor logginginterceptor = new Httplogginginterceptor ();Logginginterceptor. SetLevel(Httplogginginterceptor. level. BASIC);Marvelsigninginterceptor signinginterceptor = new Marvelsigninginterceptor (buildconfig. MARVEL_public_key, Buildconfig. MARVEL_private_key);Okhttpclient client = new Okhttpclient. Builder(). Addinterceptor(Signinginterceptor). Addinterceptor(Logginginterceptor). Build();

Otherwise, it may occur: HTTP 409 Conflict, the correct authentication method is not entered, and the private key is wrong.

6. Okhttp-logging-interceptor Output Log information

Reference, can output log information, use, the current version number is 3.0.1.

"com.squareup.okhttp3:logging-interceptor:${libs.okhttp}"

Output references:

200 OK http://gateway.marvel.com/v1/public/characters?

offset=0&... (1552ms, unknown-length body)

7. Transparent StatusBar and full screen ImageView

The status bar is set to a transparent color.

    name="AppTheme.NoStatusBar">        <itemname="android:windowTranslucentStatus">true</item>    </style>

The root layout of the page is CollapsingToolbarLayout .

<android. Support. Design. Widgets. CollapsingtoolbarlayoutXmlns:android="Http://schemas.android.com/apk/res/android"Android:layout_width="Match_parent"android:layout_height="Match_parent"Android:fitssystemwindows="true"> <imageview android:layout_width="Match_parent"android:layout_height="Match_parent"android:contentdescription="@null"Android:fitssystemwindows="true"Android:scaletype="Centercrop"Android:src="@drawable/christmas"/></android. Support. Design. Widgets. Collapsingtoolbarlayout>

Effect

8. Android Studio Templates

Location: File->other settings->default settings->editor->live Templates
After proficiency, according to shorthand +tab can be used, of course, can also join.

Define your own Template:
abbreviation (abbreviation), descriptive narrative (Description), content (Template text), application scenario, formatting.

9. Recommended sites for animated effects

URL, the site has a lot of fun animation effect, and are programmed to achieve, easy to transplant, such as snowflake effect.

Viewholder of the ListView

Android officially recommends using Recyclerview instead of a ListView, but many old-fashioned people don't want to do it, so they need to use Viewholder to boost loading speed. References.

Basic use method.

Static Class Viewholder () {TextView testname;TextView Testdesc;} ... @Overridepublic view getView (int position, view Convertview, ViewGroup parent) {View Rowview = Convertview;Initialize Viewholder if (Convertview = = null) {Layoutinflater Inflater = (layoutinflater) Parent. GetContext(). Getsystemservice(Context. LAYOUT_inflater_service);Rowview = Inflater. Inflate(R. Layout. View_test_row, parent, false);Viewholder Viewholder = new Viewholder ();Viewholder. TestName= (TextView) rowview. Findviewbyid(R. ID. Test_tv_name);Viewholder. Testdesc= (TextView) rowview. Findviewbyid(R. ID. Test_TV_DESC);Rowview. Settag(Viewholder);}//Using viewholder viewholder holder = (viewholder) rowview. Gettag();Holder. TestName. SetText("Test:"+ position);Holder. Testdesc. SetText(" This is number"+ Position +". ");Return Rowview;}

OK, that ' s all! Enjoy it.

Android Development Tips (3)

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.