欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android APP登陸頁面適配的實現(xiàn)

 更新時間:2018年09月06日 08:19:09   作者:FullScreenDev  
這篇文章主要介紹了android APP登陸頁面適配的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

本文介紹了android APP登陸頁面適配的實現(xiàn),分享給大家,具體如下:

先看效果圖。

登陸首頁效果圖

原理

為RootView增加監(jiān)聽事件,然后進行滾動

至于該滾動多少,這是需要自己慢慢進行計算。

xml

<LinearLayout
    android:id="@+id/llLogin"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">
    <!--你的布局-->
</LinearLayout>

代碼

/**
 * 1、大于屏幕整體高度的1/3:鍵盤顯示 獲取Scroll的窗體坐標(biāo)
 * 算出main需要滾動的高度,使scroll顯示。
 * 2、小于屏幕整體高度的1/3:鍵盤隱藏
 *
 * @param rootView  根布局
 */
private fun addLayoutListener(rootView: View) {
  rootView.viewTreeObserver.addOnGlobalLayoutListener {
    val rect = Rect()
    rootView.getWindowVisibleDisplayFrame(rect)
    val screenHeight = rootView.rootView.height
    val mainInvisibleHeight = rootView.rootView.height - rect.bottom
    if (mainInvisibleHeight > screenHeight / 4) {
      rootView.scrollTo(0, DensityUtils.dp2px(mActivity, 200f/*需要滾動到圖片目標(biāo)高度*/))
    } else {
      rootView.scrollTo(0, 0)
    }
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論