2010-05-16 62 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 > 
相關問題