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.
1. Uiautomatorviewer
Automated testing is the trend of Android testing, stable \ Multiplexing, the most commonly used tool is espresso.
Use Uiautomatorviewer to get the ID of the resource,
Location/android-sdk/tools/uiautomatorviewer, click to use.
2. GitHub tags
URLs, such as:
3. Interesting modifications to the SVG library
Address, load the SVG format picture, modify the 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 automatically generated class plug-in, in the command+n inside.
Attached to a plug-in, other casual.
5. How to set the Interceptor of RETROFIT2+OKHTTP3
Retrofit upgrade to the BETA3 version, 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 is 3.0.1.
"com.squareup.okhttp3:logging-interceptor:${libs.okhttp}"
Output reference:
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, you can add it yourself.
Custom templates:
abbreviation (abbreviation), description (Description), content (Template text), application scenario, formatting.
9. Recommended animated Sites
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 do not want to do so, and they also need to use Viewholder to boost loading speed. Reference.
Basic usage.
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)