Java 如何将复选框合并到可滚动窗口?

Java 如何将复选框合并到可滚动窗口?,java,android,checkbox,Java,Android,Checkbox,我想将复选框合并到LinearLayout上的一个可滚动窗口。对不起,我的英语不好 这有什么办法吗?我是java新手。我对每个复选框都有一个条件 <CheckBox android:id="@+id/checkBox7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/emod1"

我想将复选框合并到LinearLayout上的一个可滚动窗口。对不起,我的英语不好 这有什么办法吗?我是java新手。我对每个复选框都有一个条件

<CheckBox
        android:id="@+id/checkBox7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/emod1"
        android:textSize="@dimen/texty_v_menu" />

<!-- ... and 5 another checkBoxes... -->
预览:


根据复选框的CompoundButton.OnCheckedChangeListener,您可以调用以下方法。与输入参数中一样,提供对要使用平滑过渡折叠/展开的视图的引用

/**
 * Allows a view to be collapsed and Gone with a smooth animation
 * @param v view to be collapsed and gone
 */
public static void collapseView(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    final Animation a = new Animation(){
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if(interpolatedTime == 1){
                v.setVisibility(View.GONE);
            }else{
                v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    a.setDuration(500);
    v.startAnimation(a);
}


/**
 * Allows a collapsed and Gone view to be expanded and Visible
 * @param v view to be expanded and Visible
 */
public static void expandView(final View v) {
    v.measure(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    final int targtetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation(){
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? LayoutParams.WRAP_CONTENT
                    : (int)(targtetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    a.setDuration(500);
    v.startAnimation(a);
}

你说的可滚动窗口是什么意思?是否要根据复选框选择折叠/展开布局?单击箭头或文本复选框时,我希望在复选框文本下方显示/隐藏折叠/展开复选框。可能吗?我没有声誉添加一个img。上传你的图像到一些免费的服务器和粘贴的网址这里是我的应用程序的图片。我想在单击上面的文本时显示/隐藏复选框。文本是一个文本视图@Waqas@PatrikBorzecky看看我的答案。它将允许您使用平滑过渡折叠或展开视图