Android_ScrollView(滚动视图)

1.垂直滚动:Scroll 

2.水平滚动:HorizontalScrollView

(1)垂直方向滚动时 layout_width 要设置为 match_parent,layout_height 要设置为wrap_content

 (2)水平方向滚动时 layout_width 要设置为wrap_content,layout_height 要设置为match_parent

(3)滚动视图节点下面必须只能挂着一个子布局子节点,否则运行时会报错java.lang.IllegalStateException: ScrollView can host only one direct child

1.改变这个布局文件的根布局:把根布局改成:ScrollView

注意:ScrollView的子元素只能有一个,所以得增加一个LinearLayout布局,把其他按键放在这个LinearLayout中,那么ScrollViewd的子元素就只有一个LinearLayout了,而LinearLayout的子元素不限制。
 

 

猜你喜欢

转载自blog.csdn.net/weixin_38107457/article/details/121002780