跳至主要内容

博文

目前显示的是 二月, 2017的博文

android animation set

AnimationSet animationSet= new AnimationSet(getApplicationContext() ,null ) ; animationSet.addAnimation( new AlphaAnimation( 0f , 1f )) ; animationSet.addAnimation( new TranslateAnimation( 0 , 0 , editText_repeat .getHeight() , 0 )) ; animationSet.setDuration(getResources().getInteger(android.R.integer. config_shortAnimTime )) ; editText_repeat .startAnimation(animationSet) ;

android check email format

public static boolean isEmailValid ( String email ) { boolean isValid = false ; String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$" ; CharSequence inputStr = email ; Pattern pattern = Pattern . compile ( expression , Pattern . CASE_INSENSITIVE ); Matcher matcher = pattern . matcher ( inputStr ); if ( matcher . matches ()) { isValid = true ; } return isValid ; }

android fab button

gradle file: compile 'com.android.support:appcompat-v7:25.2.0' compile 'com.android.support:design:25.2.0' layout.xml <android.support.design.widget.FloatingActionButton android :layout_width= "wrap_content" android :src= "@android:drawable/ic_media_play" android :elevation= "6dp" android :background= "@color/colorAccent" android :layout_margin= "16dp" app :pressedTranslationZ= "12dp" android :layout_height= "wrap_content" /> Theme.AppCompat class extend AppCompatActivity

android layout example

android overridePendingTransition Slide

92 down vote If you want the transition work for whole application you can create a  rootacivity  and inherit it in the activity you need. In Root Activity's onCreate call  overridePendingTransition  with desired direction. And  onStart  call  overridePendingTransition  with other direction if activity is resumed. Here I am giving full running code below.Correct me if I am wrong. create this xml file on your anim folder anim_slide_in_left.xml <? xml version = "1.0" encoding = "utf-8" ?> <set xmlns:android = "http://schemas.android.com/apk/res/android" > <translate android:duration = "600" android:fromXDelta = "100%" android:toXDelta = "0%" > </translate> </set> anim_slide_in_right.xml <? xml version = "1.0" encoding = "utf-8" ?> <set xmlns:android = "http://schemas.android.com/apk/res/android" &

android scale animation

public void scaleViewY (View v , float startScale , float endScale) { Animation anim = new ScaleAnimation( 1f , 1f , // Start and end values for the X axis scaling startScale , endScale , // Start and end values for the Y axis scaling Animation. RELATIVE_TO_SELF , 0f , // Pivot point of X scaling Animation. RELATIVE_TO_SELF , 0.5f ) ; // Pivot point of Y scaling anim.setFillAfter( true ) ; // Needed to keep the result of the animation anim.setDuration( 500 ) ; v.startAnimation(anim) ; }

android immerge navigation bar & status bar

https://developer.android.com/training/system-ui/immersive.html http://niorgai.github.io/2016/03/20/Android-transulcent-status-bar/ if (Build.VERSION. SDK_INT >= Build.VERSION_CODES. LOLLIPOP ) { float [] floats= new float [ 3 ] ; getWindow().setNavigationBarColor(Color. HSVToColor ( 0 , floats)) ; getWindow().setStatusBarColor(Color. HSVToColor ( 0 , floats)) ; this .findViewById(Window. ID_ANDROID_CONTENT ).setSystemUiVisibility( View . SYSTEM_UI_FLAG_LAYOUT_STABLE | View . SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View . SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION ) ; }

Android navigation bar color setup

It can be done using <item name="android:navigationBarColor">@color/theme_color</item> or window.setNavigationBarColor(@ColorInt int color) http://developer.android.com/reference/android/view/Window.html#setNavigationBarColor(int) Note that the method was introduced in Android Lollipop and won't work on API version < 21. The second method (works on KitKat) is to set windowTranslucentNavigation to true in the manifest and place a colored view beneath the navigation bar.

You need to use a Theme.AppCompat theme (or descendant) with this activity

The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending  ActionBarActivity  which requires the  AppCompat  theme to be applied. Change the Java inheritance from  ActionBarActivity  to  Activity  and leave the dialog theme in the manifest as it is.

android write external file

Permission : writeExternalStorage public boolean isStoragePermissionGranted() { if (Build.VERSION. SDK_INT >= 23 ) { if (checkSelfPermission(Manifest.permission. WRITE_EXTERNAL_STORAGE ) == PackageManager. PERMISSION_GRANTED && checkSelfPermission(Manifest.permission. READ_EXTERNAL_STORAGE ) == PackageManager. PERMISSION_GRANTED ) { Log. v ( TAG , "Permission is granted" ); return true ; } else { Log. v ( TAG , "Permission is revoked" ); ActivityCompat. requestPermissions ( this , new String[]{Manifest.permission. WRITE_EXTERNAL_STORAGE }, 1 ); ActivityCompat. requestPermissions ( this , new String[]{Manifest.permission. READ_EXTERNAL_STORAGE }, 1 ); return false ; } } else { //permission is automatically granted on sdk<23 upon installation Log. v ( TAG , "Permission is gra

http response

http request

arch dns server

sudo pacman -S pdnsd vim /usr/share/doc/pdnsd/pdnsd.conf cp /usr/share/doc/pdnsd/pdnsd.conf /etc/ pdnsd

go tool

go tool 下面下载聚集了很多命令,这里我们只介绍两个,fix和vet go tool fix .  用来修复以前老版本的代码到新版本,例如go1之前老版本的代码转化到go1,例如API的变化 go tool vet directory|files  用来分析当前目录的代码是否都是正确的代码,例如是不是调用fmt.Printf里面的参数不正确,例如函数里面提前return了然后出现了无用代码之类的。