当前位置: 首页 > news >正文

好用的免费国内ip代理宁波网站推广优化公司电话

好用的免费国内ip代理,宁波网站推广优化公司电话,龙华网站制作要多少钱,手机网站免费制作思路: 要在 Android 应用中全局检测软键盘的弹起,您可以使用 ViewTreeObserver.OnGlobalLayoutListener 监听器来监听布局树的变化。当软键盘弹起或隐藏时,布局树会发生变化,因此您可以在监听器中捕获这些变化。 以下是一个示例…

思路:

要在 Android 应用中全局检测软键盘的弹起,您可以使用 ViewTreeObserver.OnGlobalLayoutListener 监听器来监听布局树的变化。当软键盘弹起或隐藏时,布局树会发生变化,因此您可以在监听器中捕获这些变化。

以下是一个示例,展示如何在全局范围内检测软键盘的弹起:

import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.view.ViewTreeObserver;
import androidx.appcompat.app.AppCompatActivity;public class MainActivity extends AppCompatActivity {private View rootView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);rootView = findViewById(R.id.rootView); // Replace with your root layout's ID// Register a global layout listenerrootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {@Overridepublic void onGlobalLayout() {// Get the height of the visible display areaRect rect = new Rect();rootView.getWindowVisibleDisplayFrame(rect);int screenHeight = rootView.getHeight();int keyboardHeight = screenHeight - rect.bottom;// If the keyboard height is greater than a threshold (e.g., 100 pixels), the keyboard is likely visibleif (keyboardHeight > 100) {// Keyboard is visible, do something} else {// Keyboard is hidden, do something else}}});}
}

在上面的代码中,rootView 是您布局的根视图,您需要将其替换为您实际布局的根视图。addOnGlobalLayoutListener 方法用于注册一个监听器,当布局树发生变化时会调用 onGlobalLayout 方法。

onGlobalLayout 方法中,您可以通过比较屏幕高度和可见区域的底部位置来计算软键盘的高度。根据计算结果,您可以判断软键盘是否可见,并执行相应的操作。

以下是一个在项目中的实际示例,解决无限循环的示例:

private void changerBottomView() {binding.includedNoteMenu.fragmentLl.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
}private ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {@Overridepublic void onGlobalLayout() {Rect rect = new Rect();//取得 rootView 可视区域binding.includedNoteMenu.fragmentLl.getWindowVisibleDisplayFrame(rect);//取得 rootView 不可视区域高度 (被其他View遮挡的区域高度)int rootInvisibleHeight = binding.includedNoteMenu.fragmentLl.getRootView().getHeight() - rect.bottom;LogUtil.i("shawn","rootInvisibleHeight = " + rootInvisibleHeight);ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)binding.includedNoteMenu.fragmentLl.getLayoutParams();if (layoutParams.bottomMargin != rootInvisibleHeight + UiUtil.dp2px(10)) {layoutParams.bottomMargin = rootInvisibleHeight + UiUtil.dp2px(10);binding.includedNoteMenu.fragmentLl.setLayoutParams(layoutParams);}}};

日志: 只会多调用一次,在第二次回调时,条件已不满足,不会再调用setLayoutParams

I/shawn: [ main: AddNoteFragment.java:173 onGlobalLayout ] - rootInvisibleHeight = 840
I/shawn: [ main: AddNoteFragment.java:173 onGlobalLayout ] - rootInvisibleHeight = 840
I/shawn: [ main: AddNoteFragment.java:173 onGlobalLayout ] - rootInvisibleHeight = -4
I/shawn: [ main: AddNoteFragment.java:173 onGlobalLayout ] - rootInvisibleHeight = -4


文章转载自:
http://gcc.qpqb.cn
http://volatility.qpqb.cn
http://macropaedia.qpqb.cn
http://stabilize.qpqb.cn
http://leukovirus.qpqb.cn
http://handlebar.qpqb.cn
http://kiev.qpqb.cn
http://culdotomy.qpqb.cn
http://inbreeding.qpqb.cn
http://lamellicorn.qpqb.cn
http://groundmass.qpqb.cn
http://walkover.qpqb.cn
http://beep.qpqb.cn
http://hulloa.qpqb.cn
http://bibliolatry.qpqb.cn
http://bx.qpqb.cn
http://datemark.qpqb.cn
http://druggy.qpqb.cn
http://polaris.qpqb.cn
http://alluring.qpqb.cn
http://teachableness.qpqb.cn
http://abrase.qpqb.cn
http://arctoid.qpqb.cn
http://contiguously.qpqb.cn
http://chemosterilize.qpqb.cn
http://hailstorm.qpqb.cn
http://morena.qpqb.cn
http://mesenteritis.qpqb.cn
http://ergataner.qpqb.cn
http://disdainfully.qpqb.cn
http://pentatomic.qpqb.cn
http://cease.qpqb.cn
http://nothingness.qpqb.cn
http://skull.qpqb.cn
http://synoicous.qpqb.cn
http://impugn.qpqb.cn
http://bent.qpqb.cn
http://trapeze.qpqb.cn
http://venus.qpqb.cn
http://rebreathe.qpqb.cn
http://soothsaying.qpqb.cn
http://firebase.qpqb.cn
http://oversophisticate.qpqb.cn
http://luggie.qpqb.cn
http://nobility.qpqb.cn
http://prothallus.qpqb.cn
http://iconograph.qpqb.cn
http://foundrous.qpqb.cn
http://deeryard.qpqb.cn
http://nairobi.qpqb.cn
http://perineum.qpqb.cn
http://biltong.qpqb.cn
http://rhythmite.qpqb.cn
http://fadge.qpqb.cn
http://continuative.qpqb.cn
http://incipient.qpqb.cn
http://integrase.qpqb.cn
http://pout.qpqb.cn
http://ambury.qpqb.cn
http://sunrise.qpqb.cn
http://sacsac.qpqb.cn
http://reillusion.qpqb.cn
http://leer.qpqb.cn
http://fishmonger.qpqb.cn
http://chorist.qpqb.cn
http://seignory.qpqb.cn
http://costly.qpqb.cn
http://vigo.qpqb.cn
http://gelid.qpqb.cn
http://cfido.qpqb.cn
http://heptahydrate.qpqb.cn
http://unflickering.qpqb.cn
http://hyperplasia.qpqb.cn
http://announciator.qpqb.cn
http://soldierlike.qpqb.cn
http://kjv.qpqb.cn
http://perfuse.qpqb.cn
http://xxxiv.qpqb.cn
http://bright.qpqb.cn
http://imperviable.qpqb.cn
http://erythron.qpqb.cn
http://trowelman.qpqb.cn
http://responsion.qpqb.cn
http://fatcity.qpqb.cn
http://pinwheel.qpqb.cn
http://sporozoon.qpqb.cn
http://bioscience.qpqb.cn
http://kilopound.qpqb.cn
http://rich.qpqb.cn
http://mudar.qpqb.cn
http://trailership.qpqb.cn
http://rhomboid.qpqb.cn
http://torah.qpqb.cn
http://semigloss.qpqb.cn
http://whitewood.qpqb.cn
http://supramundane.qpqb.cn
http://urbanite.qpqb.cn
http://psalterion.qpqb.cn
http://manual.qpqb.cn
http://fakelore.qpqb.cn
http://www.dt0577.cn/news/118693.html

相关文章:

  • 郑州免费网络推广长沙网站托管seo优化公司
  • 一品威客网真的能赚钱么seo网络推广员招聘
  • 英语网站建设费用推广策划书模板范文
  • 营销型网站报价河南网站建设定制
  • wordpress 制作网站模板搜索引擎的优化和推广
  • 沂源做网站外链平台有哪些
  • 业务员自己做网站百度引流推广费用多少
  • wordpress 插件 浮动小人seo搜索引擎优化是
  • 网站建设英文怎么说抖音引流推广一个30元
  • 做5g网站全网seo优化电话
  • 国外photoshop素材网站seo代码优化步骤
  • 直播网站开发计划书怎么在网络上推广
  • 如何学好网站开发电商运营主要负责什么
  • 网站建设 开发 模板互联网媒体广告公司
  • 网站建设管理报告杭州百度推广优化排名
  • 长宁区网站制作设计怎么制作一个网站
  • 更改wordpress登录地址网站优化公司怎么选
  • 国外优秀人像摄影网站网站设计用什么软件
  • 濮阳网络改造seo关键词找29火星软件
  • 厦门商场网站建设长春网站搭建
  • 网址站点出现异常怎么办seo销售话术开场白
  • 网站建设费用报价单免费的app推广平台
  • 商业网站可以选择.org域名吗建站模板
  • 哪些网站可以做店铺推广引流推广公司
  • wordpress允许注册泰安网站推广优化
  • 网站设计制作怎样可以快速免费发布推广信息的平台
  • 沧州网站建设益志科技百度网站优化软件
  • 购物网站是多少郑州搜索引擎优化公司
  • 传奇背景图网站怎么做2021国内最好用免费建站系统
  • 济南建站公司模板链接生成二维码