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

邢台网站建设哪家公司好免费空间推荐

邢台网站建设哪家公司好,免费空间推荐,万网二手已备案域名,系统开发的需求分析阶段的重要工作之一是思路#xff1a; 要在 Android 应用中全局检测软键盘的弹起#xff0c;您可以使用 ViewTreeObserver.OnGlobalLayoutListener 监听器来监听布局树的变化。当软键盘弹起或隐藏时#xff0c;布局树会发生变化#xff0c;因此您可以在监听器中捕获这些变化。 以下是一个示例…思路 要在 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 layouts 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://www.zqtcl.cn/news/198553/

相关文章:

  • 大庆网站设计费用asp网站仿制
  • 革吉网站建设网页游戏中心大全
  • 好的网站特点京东物流网站建设特点
  • 昆明企业自助建站系统网站建设技术交流
  • 卖网站模板网站哪家做的比较好
  • 舟山网站网站建设视频网站建设应该注意什么
  • 网站建设 思维导图免费flash网站源码
  • 提供零基础网站建设教学公司wordpress悬浮下拉
  • 做网站代码难么南京市建设监理协会网站
  • 网站维护 静态页面正规企业展厅设计公司
  • 网站分享图片怎么做东莞网站优化关键词费用
  • 做摄影网站的目的域名注册和网站设计服务
  • 手表网站设计免费常州百度推广优化
  • 网站开发找聚脑网视频直播源码
  • 提供免费服务器的网站南沙电子商务网站建设
  • 厦门网站建设开发公司企业网站设计源代码
  • 微网站服务器酒店手机网站首页设计
  • 网站交互做的比较好的怎样营销网站建设
  • 电子商务网站设计代码凡科做的网站能被收录吗
  • 设计网站教程自动点击器永久免费版
  • 深圳 网站建设设计如何用公众号做网站
  • 免费微信网站制作北风淘淘网站开发
  • 建筑模型设计网站建设网站设计 分辨率
  • 网站规划包括哪些内容西部建设网站
  • 网站html静态化网站整体色彩的建设
  • 长春比较有名的做网站建设宁波网站建设联系电话查询
  • 建网站中企动力推荐网络营销外包总代理
  • 网站怎么续费网站内链检测
  • 织梦网站地图样式中国品牌网站
  • 上海金山区建设局网站临淄信息港发布信息