1. /**
    2. * 隐藏软键盘
    3. */
    4. fun hideKeyboard(activity: Activity) {
    5. val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
    6. imm.hideSoftInputFromWindow(activity.window.decorView.windowToken, 0)
    7. }
    1. // 文字渐隐渐显动画
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <set xmlns:android="http://schemas.android.com/apk/res/android">
    4. <alpha
    5. android:duration="2000"
    6. android:fillAfter="true"
    7. android:fillBefore="false"
    8. android:fromAlpha="1.0"
    9. android:interpolator="@android:anim/linear_interpolator"
    10. android:repeatMode="reverse"
    11. android:repeatCount="-1"
    12. android:toAlpha="0.1"
    13. />
    14. </set>
    15. // 代码中应用
    16. private var textAnimation:Animation = AnimationUtils.loadAnimation(requireContext(),R.anim.text_alpha_anim)
    17. view.startAnimation(textAnimation)