java - AndroidStudio - 在进行片段事务时保持布局参数(高度、宽度)
问题描述
所以我使用 FragmentTransaction 来切换到不同的片段。请看下面的代码。
现在,来自片段的两个膨胀视图都在同一个 FragmentContainerView 中使用。但是由于布局在xml中设置为wrap_content,所以FragmentContainerView的大小发生了变化。
进行交易时如何保持相同的尺寸?谢谢!
getActivity().getSupportFragmentManager()
.beginTransaction()
// Replace the default fragment animations with animator resources
// representing rotations when switching to the back of the card, as
// well as animator resources representing rotations when flipping
// back to the front (e.g. when the system Back button is pressed).
.setCustomAnimations(
R.animator.card_flip_right_in,
R.animator.card_flip_right_out,
R.animator.card_flip_left_in,
R.animator.card_flip_left_out)
// Replace any fragments currently in the container view with a
// fragment representing the next page (indicated by the
// just-incremented currentPage variable).
.replace(R.id.fragmentFoodCard, new Fragment_FoodCard_Back())
// Add this transaction to the back stack, allowing users to press
// Back to get to the front of the card.
.addToBackStack(null)
// Commit the transaction.
.commit();
}
解决方案
推荐阅读
- c# - C# SQL 连接 ODBC 或 OLEDB
- javascript - 类变量的正确类型(例如 fArr = Uint32Array)
- reactjs - 如果 action id 不存在,则 React/Redux 更新状态数组
- c# - 为什么反射器不显示IDictionary
实现 IEnumerable ? - javascript - react-native 包指定了一个主模块 https 模块
- javascript - 在 HTML5 视频标签上强制硬件加速(每个 html 或 js)
- edi - 如何区分 Liaison Delta 和 ECS 中的 XML 事务
- bash - 如何根据特定条件删除具有不同扩展名的文件?
- android - MaterialButton 在 Android 5.1.1(API 级别 22)中看起来不像“MaterialButton”
- java - 如何使用已生成的 AES 256 GCM 96 密钥(来自 Hashicorp Vault)加密数据?