android Splash Screen & Stretch OverScroll Effect,kotlin

android Splash Screen & Stretch OverScroll Effect,kotlin



import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import me.everything.android.ui.overscroll.OverScrollDecoratorHelper


class MyAdapter(private val context: Context) : RecyclerView.Adapter<MyVH>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyVH {
        val view: View =
            LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, parent, false)
        val holder = MyVH(view)
        return holder
    }

    override fun getItemCount(): Int {
        return 999
    }

    override fun onBindViewHolder(holder: MyVH, position: Int) {
        holder.text.setText(position.toString())
    }
}

class MyVH(itemView: View) : RecyclerView.ViewHolder(itemView) {
    var text: TextView

    init {
        text = itemView.findViewById(android.R.id.text1)
    }
}


class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val recyclerView = findViewById<RecyclerView>(R.id.recyclerview)
        val linearLayoutManager = LinearLayoutManager(this)
        linearLayoutManager.orientation = RecyclerView.VERTICAL
        recyclerView.layoutManager = linearLayoutManager

        OverScrollDecoratorHelper.setUpOverScroll(
            recyclerView,
            OverScrollDecoratorHelper.ORIENTATION_VERTICAL
        )

        val adapter = MyAdapter(this)
        recyclerView.adapter = adapter
    }
}

(1)Stretch OverScroll Effect, can implements by google's method, or used open source implements:

implementation 'io.github.everythingme:overscroll-decor-android:1.1.1'

(2)splash screen,in this res/values/themes.xml file config:

        <!--启动开屏页的背景颜色-->
        <item name="android:windowSplashScreenBackground">@android:color/holo_red_light</item>
        <!--启动动画的logo-->
        <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
        <!--启动logo icon的背景颜色-->
        <item name="android:windowSplashScreenIconBackgroundColor">@android:color/holo_green_light</item>
        <!--品牌-->
        <item name="android:windowSplashScreenBrandingImage">@android:drawable/ic_menu_info_details</item>
        <!--启动开屏页的显示时长-->
        <item name="android:windowSplashScreenAnimationDuration">1000</item>

Android View滚动、拉伸到顶/底部弹性回弹复位_android 页面伸缩弹性_zhangphil的博客-CSDN博客《Android View滚动、拉伸到顶/底部弹性回弹复位》我在上一篇文章介绍了如何实现一个Android ListView拉到顶/底部后,像橡皮筋一样弹性回弹复位(《Android ListView拉到顶/底部,像橡皮筋一样弹性回弹复位》,文章链接地址:http://blog.csdn.net/zhangphil/article/details/47311155 )。事实上,https://blog.csdn.net/zhangphil/article/details/47333845

Android ListView拉到顶/底部,像橡皮筋一样弹性回弹复位_listview回弹效果_zhangphil的博客-CSDN博客《Android ListView拉到顶/底部,像橡皮筋一样弹性回弹复位》Android本身的ListView拉到顶部或者底部会在顶部/底部边缘间隙出现一道“闪光”效果,暗示ListView已经到顶/底,不能再动了。 这是Android原生的ListView拉到顶部/底部的一种交互设计。交互设计的可选方案很多。Android 5.0将ListView的这个交互设计改变成“一片荡漾的https://blog.csdn.net/zhangphil/article/details/47311155

猜你喜欢

转载自blog.csdn.net/zhangphil/article/details/129408270