mih*_*iho 37 android android-appcompat
我正在使用BottomSheetBehavior谷歌最近发布的AppCompat v23.2.我的底部工作表的高度取决于底部工作表内显示的内容(类似于Google在Google地图应用中所做的工作).
它最初加载的数据工作正常,但我的应用程序更改了运行时显示的内容,当发生这种情况时,底部工作表保留在它的旧高度,这会导致底部未使用的空间或视图切割.
有任何方法来通知所述底部片材的布局重新计算用于扩展状态(当的高度的高度ViewGroup被设置为MATCH_HEIGHT)或任何方法来手动设置所需的高度?
编辑:我也尝试手动调用invalidate()在ViewGroup它和家长,但没有成功.
Phy*_*Tea 32
我RelativeLayout和我的底页有同样的问题.高度不会重新计算.我不得不求助于通过新重新计算的值设置高度并调用BottomSheetBehavior.onLayoutChild.
这是我的临时解决方案:
coordinatorLayout = (CoordinatorLayout)findViewById(R.id.coordinator_layout);
bottomSheet = findViewById(R.id.bottom_sheet);
int accountHeight = accountTextView.getHeight();
accountTextView.setVisibility(View.GONE);
bottomSheet.getLayoutParams().height = bottomSheet.getHeight() - accountHeight;
bottomSheet.requestLayout();
behavior.onLayoutChild(coordinatorLayout, bottomSheet, ViewCompat.LAYOUT_DIRECTION_LTR);
Run Code Online (Sandbox Code Playgroud)
Yui*_*aki 10
你可以用BottomSheetBehavior#setPeekHeight它.
FrameLayout bottomSheet = (FrameLayout) findViewById(R.id.bottom_sheet);
BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setPeekHeight(newHeight);
Run Code Online (Sandbox Code Playgroud)
这不会自动将底部工作表移动到窥视高度.您可以打电话BottomSheetBehavior#setState将底页调整到新的峰值高度.
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26547 次 |
| 最近记录: |