如何设置与Android的包裹内容的最大高度? [英] How to set a maximum height with wrap content in android?

查看:335
本文介绍了如何设置与Android的包裹内容的最大高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的,你怎么能打造了有一个最大高度滚动视图,并包裹内容,基本上它包装内容垂直,但有一个最大高度?

In android, how can you create a scroll view that's got a max height, and wrap contents, basically it wraps the content vertically, but has a maximum height?

我试过

<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>

但是,这是不工作?

But this isn't working?

推荐答案

我已经延长滚动型和添加code来实现此功能:

I've extended ScrollView and added code to implement this feature:

https://gist.github.com/JMPergar/439aaa3249fa184c7c0c

我希望是有用的。

这篇关于如何设置与Android的包裹内容的最大高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆