【HorizontalScrollView控件里面可以嵌套自定义ViewGroup吗?嵌套之后不显示ViewGroup里的控件。】
在网上看到的一个自定义ViewGroup控件,是一个实现3D旋转效果的容器类,
然后试图把它往HorizontalScrollView里面套,结果发现不显示。是为什么?
是因为HorizontalScrollView里面不能包含ViewGroup吗?还是其他地方有问题?
想实现多个3D旋转容器一起放在界面里,且可以横向拖动,类似于coverflow那种效果。如果这个方法不行,有没有其他思路?刚接触Android没多久,如果有明显错误的地方,希望大家直接指出,谢谢~
下面是布局代码:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<com.study.testanything.custom.StereoView
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/p12"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/p10"/>
</com.study.testanything.custom.StereoView>
</HorizontalScrollView>
下面是StereoView重写onMeasure方法的代码,如果有其他需要贴出的代码,大家请指出~
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
measureChildren(widthMeasureSpec, heightMeasureSpec);
mWidth = getMeasuredWidth();
mHeight = getMeasuredHeight();
//滑动到设置的StartScreen位置
scrollTo(0, mStartScreen * mHeight);
}