根据子项动态调整布局大小

时间:2018-06-06 15:46:13

标签: android android-layout listview

我有一个按钮,如果按下它会显示带有一些数据的ListView,问题是有时列表会被裁剪出来:

enter image description here

并且我不知道如何使de layout动态化以便列表不会裁剪,这就是我所拥有的:

 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]);

0 个答案:

没有答案