2010-05-16 114 views
2

所以,我遵循了一个在android上绘制东西的教程。我创建了一个扩展SurfaceView的Panel类,我使用线程进行绘制。现在我想把这个面板放在一个滚动视图中,特别是一个水平滚动的屏幕,以便我可以绘制比屏幕更宽的东西。我会去做这件事吗?如何将自定义视图添加到Horizo​​ntalScrollView?

回答

0

这可以在项目的XML中完成,你想要做的是,无论你想成为int scrollview,你都可以在scrollview中放入xml。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal">

和: </ScrollView>

0

想象一下,您的自定义组件被命名为(类)MyCustomComponent和它在包org.neteinstein.code

它会之间在

该xml将是:

<HorizontalScrollView android:id="@+id/scroll" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:fillViewport="true"> 

      <org.neteinstein.code.MyCustomComponent android:layout_width="fill_parent" 
       android:layout_height="fill_parent"/> 

</HorizontalScrollView > 
相关问题