• <bdo id='Lsysa'></bdo><ul id='Lsysa'></ul>
  • <tfoot id='Lsysa'></tfoot>

      <i id='Lsysa'><tr id='Lsysa'><dt id='Lsysa'><q id='Lsysa'><span id='Lsysa'><b id='Lsysa'><form id='Lsysa'><ins id='Lsysa'></ins><ul id='Lsysa'></ul><sub id='Lsysa'></sub></form><legend id='Lsysa'></legend><bdo id='Lsysa'><pre id='Lsysa'><center id='Lsysa'></center></pre></bdo></b><th id='Lsysa'></th></span></q></dt></tr></i><div id='Lsysa'><tfoot id='Lsysa'></tfoot><dl id='Lsysa'><fieldset id='Lsysa'></fieldset></dl></div>

      <small id='Lsysa'></small><noframes id='Lsysa'>

        <legend id='Lsysa'><style id='Lsysa'><dir id='Lsysa'><q id='Lsysa'></q></dir></style></legend>

        如何将 Android ViewPager2 的高度包装到当前项目的高度?

        How to wrap height of Android ViewPager2 to height of current item?(如何将 Android ViewPager2 的高度包装到当前项目的高度?)

            <tbody id='PiFWV'></tbody>
        1. <legend id='PiFWV'><style id='PiFWV'><dir id='PiFWV'><q id='PiFWV'></q></dir></style></legend>

          <small id='PiFWV'></small><noframes id='PiFWV'>

          <i id='PiFWV'><tr id='PiFWV'><dt id='PiFWV'><q id='PiFWV'><span id='PiFWV'><b id='PiFWV'><form id='PiFWV'><ins id='PiFWV'></ins><ul id='PiFWV'></ul><sub id='PiFWV'></sub></form><legend id='PiFWV'></legend><bdo id='PiFWV'><pre id='PiFWV'><center id='PiFWV'></center></pre></bdo></b><th id='PiFWV'></th></span></q></dt></tr></i><div id='PiFWV'><tfoot id='PiFWV'></tfoot><dl id='PiFWV'><fieldset id='PiFWV'></fieldset></dl></div>
        2. <tfoot id='PiFWV'></tfoot>

                  <bdo id='PiFWV'></bdo><ul id='PiFWV'></ul>
                • 本文介绍了如何将 Android ViewPager2 的高度包装到当前项目的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这个问题是针对新的 ViewPager2 类的.

                  This question is for the new ViewPager2 class.

                  有一个 旧 ViewPager 的类似问题,但解决方案需要扩展 ViewPager.但是,ViewPager2 是最终版本,因此无法扩展.

                  There is a similar question for the old ViewPager, but the solution requires extending ViewPager. However, ViewPager2 is final so cannot be extended.

                  在我的情况下,我有一个包含三个不同片段的 ViewPager2.其中一个片段比其他两个片段高得多,这意味着当您滑动到其中一个较短的片段时,会有很多空白空间.那么如何有效地将 ViewPager2 包裹到当前 Fragment 的高度呢?

                  In my situation, I have a ViewPager2 that contains three different fragments. One of these fragments is much taller than the other two, which means when you swipe to one of the shorter fragments, there is a lot of empty space. So how do I effectively wrap the ViewPager2 to the height of the current fragment?

                  推荐答案

                  解决方案是在 ViewPager2 的每个片段中添加以下内容:

                  The solution is to add the following in each fragment that is part of the ViewPager2:

                  override fun onResume() {
                     super.onResume()
                     binding.root.requestLayout()
                  }
                  

                  binding.root 来自 ViewBinding/DataBinding 但它是布局的主要容器,即 ConstraintLayoutLinearLayout 等.

                  binding.root is from ViewBinding/DataBinding but it's is the main container of your layout, i.e. ConstraintLayout, LinearLayout, etc.

                  这篇关于如何将 Android ViewPager2 的高度包装到当前项目的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
                  cocos2d-android: how to display score(cocos2d-android:如何显示分数)
                  Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                  SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                  Android file copy(安卓文件拷贝)
                  Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)

                • <i id='oiKGf'><tr id='oiKGf'><dt id='oiKGf'><q id='oiKGf'><span id='oiKGf'><b id='oiKGf'><form id='oiKGf'><ins id='oiKGf'></ins><ul id='oiKGf'></ul><sub id='oiKGf'></sub></form><legend id='oiKGf'></legend><bdo id='oiKGf'><pre id='oiKGf'><center id='oiKGf'></center></pre></bdo></b><th id='oiKGf'></th></span></q></dt></tr></i><div id='oiKGf'><tfoot id='oiKGf'></tfoot><dl id='oiKGf'><fieldset id='oiKGf'></fieldset></dl></div>

                  • <legend id='oiKGf'><style id='oiKGf'><dir id='oiKGf'><q id='oiKGf'></q></dir></style></legend>

                    <small id='oiKGf'></small><noframes id='oiKGf'>

                    • <bdo id='oiKGf'></bdo><ul id='oiKGf'></ul>

                          <tfoot id='oiKGf'></tfoot>

                            <tbody id='oiKGf'></tbody>