以为ScrollView只能嵌套一个元素,所以把几个控件都包裹在了一个LinearLayout中了。但是发现底部显示不全,滑动不到最底下。
代码:

<ScrollView        android:id="@+id/scrollView"        android:layout_width="fill_parent"        android:layout_height="wrap_content">     <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_marginTop="10dp"            android:background="@color/colorWhite"            android:orientation="vertical"            android:padding="15dp">            <TextView                android:id="@+id/tv_detail_name"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="Hibernate注解"                android:textColor="#262626"/>            <TextView                android:id="@+id/tv_detail_description"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_marginTop="10dp"                android:ellipsize="end"                android:maxLines="5"                android:text="Hibernate注解详细描述"                android:textSize="12sp"/>        LinearLayout> ScrollView>

原因是什么呢?
其实就是LinearLayout中的

android:layout_marginTop="10dp"

这样,ScrllView在开始显示的时候就会向下移10dp。解决办法有很多种
1、把android:layout_marginTop=”10dp”加给ScrllView
2、给Linearlayout再加上两个属性:

     android:paddingTop="10dp"     android:paddingBottom="8dp"

其实我们还可以直接把ScrllView作为跟布局的,这样就简单很多。

好啦,就是这样。问题不限于嵌套Linearlayout,其他的道理也是一样的。

有问题欢迎提出。

哦对了,欢迎大家加群一起交流,群主是多年开发经验的大牛:

扣扣群号:454430053

转载于:https://www.cnblogs.com/codenoodles/p/6421182.html

更多相关文章

  1. 居中显示并旋转 android Button 里的属性drawableLeft
  2. android ListView中自定义SimpleAdapter动态添加ratingBar及图片
  3. 高通Android(安卓)display架构分析
  4. Activity伪造Dialog的时候不能全屏显示
  5. Android(安卓)4.2一些变动
  6. AOP面向切面编程
  7. 检索Android的图片库,并显示
  8. 如何让android应用程序用中文显示(应用程序名称本地化)
  9. Android的Fragment中onActivityResult不被调用的解决方案(绝对管

随机推荐

  1. Android(安卓)实现Activity后台运行
  2. Android(安卓)同个TextView设置字体大小
  3. Android(安卓)HTTP GET/POST
  4. Android: Bluetooth profile list for 2.
  5. Android(安卓)系统操作
  6. android屏蔽home键
  7. android语音识别和语音播报相关资料总结
  8. Android(安卓)点击按钮,文字改变颜色
  9. android 给图片加水印
  10. android 使用动画 Button移动后不响应点