您的位置:首页 > 其它

viewpager不显示

2015-09-21 06:48 369 查看
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>

<com.example.shijianlanjie.scrollChangeView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scv">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="200dp"
android:layout_height="200dp"
>
</android.support.v4.view.ViewPager>
</LinearLayout>
</com.example.shijianlanjie.scrollChangeView>
</LinearLayout>

如果将Viewpager的layout_width和layout_height设置为match_parent结果什么都不显示,不知道viewpager的源码是怎么判断宽高的

通常onmeasure有三种类型,MOST为最大要多少,unspecified基本没有意义,还有EXACTLY类型,match_parent应该是EXACTLY的类型,就是父空间有多少,就占据多少,但是这里显示为0

可能和外部嵌套的scrollChangeView有关,这是一个自定义布局,继承Horizonscrollview,这种伸缩布局似乎即使是设置为match_parent,原始大小其实也是0,因为大小是随着子view而不断改变的,所以其实可能相当于wrap_content,原始大小其实是0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  viewpager不显示