我有这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="21474836px"
android:text="TextView" />
</RelativeLayout>
</ScrollView>
但是没有显示,我把2147483647px改成214748364px,有文字显示但是不滚动,改成21474836px后一切正常。
谁能解释一下?这里的最大值是多少?
更新:我想用超大 View 实现半无限 View ,这里用px代替dp,因为不知道有没有限制,是否用px还是dp表示?
最佳答案
这种布局的一些问题:
1) 不建议以px
为单位给出尺寸。坚持 dp
。
2) 你没有指定宽度属性。这真的编译了吗?
3) RelativeLayout
需要什么?
也就是说,让系统使用 android:height="fill_parent"
或 android:height="wrap_content"
来确定所需的高度。
关于android - View 高度的最大允许值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11687445/