android小细节

来源:互联网 发布:基于mac的acl 编辑:程序博客网 时间:2024/05/18 02:44
<style name="Theme.Translucent.NoTitleBar">    <item name="windowNoTitle">true</item>    <item name="windowContentOverlay">@null</item></style>

1.在引导页加上以上代码,可以一开始就显示背景图,而不显示白色背景。

以及去除引导页title.


2.ListView

android:clipToPadding用于ListView滑动时忽略padding。



3.actionBar更改返回图标的方法:

1.要求API版本大于18

  ActionBar ab = getSupportActionBar();  ab.setDisplayHomeAsUpEnabled(true);  ab.setHomeAsUpIndicator(R.drawable.ic_menu);
2.更改样式

在style.xml文件中新增样式

<style name="style_normal" parent="Theme.AppCompat.Light">          <item name="android:homeAsUpIndicator">@drawable/back</item> <!--返回icon-->   </style> 

然后在Activity中使用该样式


4.Toast频繁显示

可以自己实现帮助类,每次使用Toast都是对同一个Toast进行设置

public class ToastHelper {    public static Toast toast = null;    public static void showToast(Context context,String content,int duration){        if(toast == null){            toast = Toast.makeText(context,content,duration);        }else{            toast.setText(content);            toast.setDuration(duration);        }        toast.show();    }    public static void cancelToast(){        if(toast != null){            toast.cancel();        }    }}


0 0
原创粉丝点击