我试图在替换fragments(with replace()of fragment transaction)时使用动画。我用setCustomAnimations(). 我animation正在尝试将旧的fragment与从右侧移动的新的重叠。但问题是:fragment即使旧视图已经与新视图重叠,我也可以看到旧视图。views只有当动画完成时,旧的才会消失。另外,当一个新的fragment很复杂(listviews,等等...)时,我可以看到一些人工制品,并且在重叠时会闪烁。这太可怕了,我怎样才能避免这种情况?
我的输入代码animation:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="together">
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:propertyName="x"
android:valueType="floatType"
android:valueTo="0"
android:valueFrom="720"
android:duration="250"
android:zAdjustment="top"/>
</set>
Run Code Online (Sandbox Code Playgroud)
更新:关于人工制品——不是它们。这只是覆盖不良的后果。我慢慢看动画。所以问题是:旧片段停留在 TOP 上。它在动画时完全重叠新的。
我需要在SharedPreferences中存储一些私有用户的值.
我看到了这篇文章:https: //medium.com/@ericfu/securely-storing-secrets-in-an-android-application-501f030ae5a3
它解释了您需要做的大部分事情,但似乎缺少关于如何将私钥和公钥(对于API <23)保存到密钥库中的部分.
因此,如果我们有API版本18-22,我们会执行以下操作:我们打开一个密钥库
KeyStore keyStore = KeyStore.getInstance(AndroidKeyStore);
keyStore.load(null);
Run Code Online (Sandbox Code Playgroud)
我们生成密钥对
Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance();
end.add(Calendar.YEAR, 30);
KeyPairGeneratorSpec spec = new KeyPairGeneratorSpec.Builder(mContext)
.setAlias(KEY_ALIAS)
.setSubject(new X500Principal("CN=" + KEY_ALIAS))
.setSerialNumber(BigInteger.TEN)
.setStartDate(start.getTime())
.setEndDate(end.getTime())
.build();
KeyPairGenerator kpg = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, AndroidKeyStore);
kpg.initialize(spec);
mEncryptionPair = kpg.generateKeyPair();
Run Code Online (Sandbox Code Playgroud)
现在我们可以使用公钥加密数据和私钥来解密它.但是我们需要将密钥对保存到密钥库并稍后检索它.我该怎么做?
我还担心Android Studio为什么会显示此行的警告
KeyPairGenerator kpg = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, AndroidKeyStore);
Run Code Online (Sandbox Code Playgroud)
警告:
Field requires API level 23 (current min is 14): android.security.keystore.KeyProperties#KEY_ALGORITHM_RSA
Run Code Online (Sandbox Code Playgroud) 这是我的styles.xml 文件
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#6d3655</item>
<item name="colorPrimaryDark">#442142</item>
<item name="colorAccent">#de8573</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)
我想从我的布局访问 colorPrimary。例如,我尝试将颜色应用于某些 TextField。我将“textColor”属性设置为“@style/AppTheme.colorPrimary”,但它不起作用。为什么?