timeText.setText(Utils.getCurrentTime());//设置显示时间,默认HH:mm,可以使用Utils.getCurrentTime(format)设置显示格式
private void bindReceiver() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_TIME_TICK);// 每分钟更新,只能采用代码registerReceiver动态注册方式
intentFilter.addAction(Intent.ACTION_TIME_CHANGED); // 时间被改变,人为设置时间
timeUpdateBroadcastReceiver = new TimeUpdateBroadcastReceiver(new CommonListener() {
@Override
public Object onExecute(Object o) {
//更新时间
timeText.setText(o.toString());
return null;
}
});
getActivity().registerReceiver(timeUpdateBroadcastReceiver, intentFilter);
}
//用默认的SharedPreferences
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
String value= sharedPreferences.getString("key", "");
//svg与webview的自适应问题
参考http://www.zhangxinxu.com/wordpress/2014/08/svg-viewport-viewbox-preserveaspectratio/comment-page-1/
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="100%" height="12000px"preserveAspectRatio="xMidYMin meet" viewBox="0 0 405.07 13521.26" enable-background="new 0 0 405.07 13521.26"
xml:space="preserve">
修改svg的属性 width 并加上preserveAspectRatio
详细分析见连接