Android--时间相关--笔记

 //通过传入回溯时间,传出相应开始时间,这里为小时数
    public String getTime(int backTime) {

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - backTime);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
        
        return df.format(calendar.getTime());
    }


简单加密解密 Base64:

String accountBase64 = Base64.encodeToString(account.getBytes(), Base64.DEFAULT);<pre name="code" class="html">new String(Base64.decode(string.getBytes(), Base64.DEFAULT));




这两天一直想把一个activity  (extends AppcompatActivity )显示一部分,因为布局只有一部分,并不会填满

通过更改theme,使用了其自带的dialog,不是存在标题就是背景色填满(@null也是)

后来找到一个方案,把背景色页给自定义掉

<style name="AlertNoActionBar" parent="@style/Theme.AppCompat.Light.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="android:windowFrame">@null</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowIsTranslucent">false</item>
        <item name="android:windowNoTitle">true</item><!--除去title-->
        <item name="android:windowContentOverlay">@null</item>
        <!-- <item name="android:backgroundDimEnabled">false</item> -->
        <item name="android:windowBackground">@drawable/xml_seat_shape</item> <!--除去背景色-->
    </style>

xml_seat_shape

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:Android="http://schemas.android.com/apk/res/android" >
    <solid Android:color="#00000000" />
    <padding
        Android:bottom="5dp"
        Android:left="5dp"
        Android:right="5dp"
        Android:top="5dp" />
    <stroke
        Android:width="2dp"
        Android:color="#00000000" />
    <corners Android:radius="5dp" />
</shape>

在布局那里设置背景颜色的时候,也有用过#00000000,但是没有成功,也是奇怪。来日再究


文本超链接,可以使用Linkfy 和 xml属性autolink

你可能感兴趣的:(Android--时间相关--笔记)