跳至主要内容

博文

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

android Button add ripple effects

Method 1:  To Add Ripple Effect/Animation to a Android Button Just replace your button background attribute with  android:background="?attr/selectableItemBackground"  and your code looks like this. < Button android : layout_width = " match_parent " android : layout_height = " wrap_content " android : background = " ?attr/selectableItemBackground " android : text = " Click Me " /> view raw button_ripple_effect.xml  hosted with ❤ by  GitHub Method 2:  To Add Ripple Effect/Animation to a Android Button Using this method, you can customize ripple effect color. First, you have to create a xml file in your drawable resource directory. Create a  ripple_effect.xml  file and add following code. res/drawable/ripple_effect.xml <? xml version = " 1.0 " encoding = " utf-8 " ?> < ripple xmlns : android = " http://schemas.android.com/apk/res/andr

javascript upload file with progress bar (xml request)

<!DOCTYPE html> <html> <head> <title>my title</title> <meta name="viewport" content="width=device-width initial-scale=1 maximum-scale=1"> <script type="text/javascript"> function up() {         if (document.getElementById("f").value == "") {             document.getElementById("result").innerHTML = "请选择文件";         }         else {             var fileObj = document.getElementById("f").files[0];             //创建xhr             var xhr = new XMLHttpRequest();             var url = "uploadFile";             //FormData对象             var fd = new FormData();             fd.append("path", "D:\\");    //上传路径             fd.append("file", fileObj);             fd.append("acttime",new Date().toString());    //本人喜欢在参数中添加时间戳,防止缓存(--、)             xhr.onreadystatechange = function () {                 i

android open file provider type

add a FileProvider tag in AndroidManifest.xml under tag. <? xml version = "1.0" encoding = "utf-8" ?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" ... <application ... <provider android:name = "android.support.v4.content.FileProvider" android:authorities = "${applicationId}.provider" android:exported = "false" android:grantUriPermissions = "true" > <meta-data android:name = "android.support.FILE_PROVIDER_PATHS" android:resource = "@xml/provider_paths" /> </provider> </application> </manifest> then create a provider_paths.xml file in xml folder under res folder. Folder may be needed to create if it doesn't exist. The content of the file is shown below. It describes that we would like to

android pop up menu

使用方法 res/menu下面新建 popup_menu.xml <menu   xmlns:android = "http://schemas.android.com/apk/res/android"          xmlns:tools = "http://schemas.android.com/tools" >    <item       android:id = "@+id/special_topic"          android:title = "专题" />           <item             android:id = "@+id/elite"             android:title = "精选" />      </menu> 在activity或者fragment中使用PopupMenu         final    ImageButton  moreMenu  =   ( ImageButton ) v . findViewById ( R . id . more_menu );         moreMenu . setOnClickListener ( new   OnClickListener ()   {              @Override              public   void  onClick ( View  v ){                     PopupMenu  popup  =   new   PopupMenu ( getActivity (),  moreMenu );                      //Inflating the Popup using xml file                     popup . getMenuInflater ()                          . inflate ( R . menu . poupup_menu_home ,  pop