android - 根据子项动态调整布局大小
问题描述
我有一个按钮,如果按下它会显示一个带有一些数据的 ListView,问题是有时列表会像这样被裁剪出来:
而且我不知道如何使布局动态化,因此列表不会裁剪,这就是我所拥有的:
pullDownArrow = (ImageView) view.findViewById(R.id.pull_down_arrow);
topMenuLayout = (RelativeLayout) view.findViewById(R.id.menu_top);
topMenuContainer = (LinearLayout) view.findViewById(R.id.menu_top_container);
listView = (ListView) getView().findViewById(R.id.listview);
final int childNum = topMenuContainer.getChildCount() + listaCuentas.size();
final int layoutHeight = (childNum * 37 + 70);
final ResizeAnimation[] resizeAnimation = {null};
pullDownArrow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (topMenuExpanded) {
resizeAnimation[0] = new ResizeAnimation(topMenuLayout, dptopx(5));
topMenuExpanded = false;
} else {
resizeAnimation[0] = new ResizeAnimation(topMenuLayout, dptopx(layoutHeight));
topMenuExpanded = true;
}
resizeAnimation[0].setDuration(300);
topMenuLayout.startAnimation(resizeAnimation[0]);
解决方案
推荐阅读
- r - 如何使用 laply match 查找值并附加到每一行?
- python - 如何将输入作为参数传递给 python 中的另一个函数?它没有
- ios - 由于内部保留周期,ViewController 没有被释放
- logstash - 如何在logstash输入文件中使用正则表达式
- android - 无法使用polidea RxAndroidBLE断开android中的蓝牙
- jquery - JQuery 在媒体查询更新元素之前运行
- c# - C# Toast Win32 [以管理员身份运行] 不起作用
- jquery - jQuery:在页面加载时未选择正确的下拉值
- java - 带有连接的 JPA 标准构建器包装器
- json - 如何改进将数千个微小的 JSON 文件加载到 Spark 数据帧中?