Android ScrollView 的内容显示不全
ScrollView中的LinearLayout本来是能正常显示的,但是在添加了第18行语句:
android:layout_marginTop="20dp"
之后,上面多出来了20dp的边距,这是对的。
但是为什么下边却少了20dp呢? 导致滚动条拖不到最低端,所以最下面的按钮显示不全。
这是怎么回事?xml代码如下:
<RelativeLayout--------------------编程问答-------------------- 加上layout_marginBottom --------------------编程问答-------------------- 请问你知道为什么会出现这种现象吗?? 好奇怪 --------------------编程问答-------------------- 这个问题是因为,你加了marginTop之后,scrollView初始显示的位置向下移动了20dp,你如果想要让他正常显示,必须在代码里面设置一下scrollView的初始显示位置就可以了。mScrollView.smoothScrollTo(0,0). --------------------编程问答-------------------- 可以设置scrollview的 paddingTop=20,不要设置里面的marginTop ,试试 --------------------编程问答-------------------- MLGB的 结贴啊
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="200dp"
android:layout_height="200dp"
android:scrollbars="vertical"
android:background="@android:color/background_dark" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@android:color/holo_blue_light" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
补充:移动开发 , Android