1 问题:
ScrollView嵌套TextView,TextView中文字很多时,会出现文字上部被截断几行,控件底部又出现了一块空白
问题布局
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginBottom="24dp"
android:layout_marginTop="24dp"
android:clipToPadding="false"
android:overScrollMode="never" >
<TextView
android:id="@android:id/message"
style="@style/TextAppearance.Xui.Subhead"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:lineSpacingExtra="3dp"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="left|top"
android:text="1时间: 2016年6月21日 上午11:53
\n2宽度: 1080
\n3高度: 1920
\n4文件大小: 89.19K
\n5路径: /storage/emulated/0/DCIM/storage/emulated/0/DIM/storage/emulated/0/DCIM
\n6修改时间: 2016年5月11日 下午10:11
\n7作者: 没有人
\n8其他信息1: 填充用字符串
\n9其他信息2: 填充用字符串填充用字符串填充用字符串填充用字符串填充用字符串填充用字符串填充用字符串
\n10其他信息3: 填充用字符串
\n11其他信息4: 填充用字符串"
android:textColor="@android:color/holo_orange_dark" />
</ScrollView>
截图如下:
2.解决:
去掉TextView的 gravity 属性,即:
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="left|top"