首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

ScrollView添加自定义view显示不完全?该怎么解决

2012-04-14 
ScrollView添加自定义view显示不完全????????????????如下所述:情况一:LinearLayoutxmlns:androidhttp:

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的宽和高。

热点排行