读书人

ScrollView添加自定义view显示不完全?

发布时间: 2012-04-14 17:14:21 作者: rapoo

ScrollView添加自定义view显示不完全????????????????
如下所述:
情况一:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.views.myView
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
</LinearLayout>
显示:


情况二:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.views.myView
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
</ScrollView>
</LinearLayout>
显示:


怎么设置myView才能全部显示呢..

[解决办法]
ScrollView加属性android:fillViewport="true"
[解决办法]
自定义的View一定要重载实现public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)函数,在其中调用setMeasuredDimension函数,设置自定义的View的宽和高。

读书人网 >Android

热点推荐