View有一个minHeight但不知何故缺少一个maxHeight:
我想要实现的是让一些项目(视图)填满ScrollView.当有1..3项时,我想直接显示它们.意味着它ScrollView具有1,2或3个项目的高度.
当有4个或更多项目我希望ScrollView停止扩展(因此a maxHeight)并开始提供滚动.
但是,遗憾的是没有办法设置maxHeight.因此,我可能必须以ScrollView编程方式WRAP_CONTENT将高度设置为有1..3项3*sizeOf(View)时的高度,并将高度设置为有4个或更多项时的高度.
任何人都可以解释为什么没有maxHeight提供,什么时候已经有minHeight?
(顺便说一下:有些观点,比如ImageView已经maxHeight实施了.)
在android中,如何创建一个具有最大高度的滚动视图,并包装内容,基本上它是垂直包装内容,但具有最大高度?
我试过了
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="200dp"
android:layout_alignParentBottom="true" >
<LinearLayout
android:id="@+id/maincontainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
但这不起作用?