How can I add a custom view to the HorizontalScrollView?

So, I followed the drawing tutorial on Android. I created a Panel class that extends the SurfaceView I am using using a stream. Now I want to put this panel in scroll mode, specifically scroll horizontally so that I can draw material wider than the screen. Would I do it?

+2


a source to share


2 answers


this can be done in the XML of the project, what you want to do, whatever you want to include in the scrollview, you put inside the scrollview in the xml. it will be in between:

<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">



and: </ScrollView>

0


a source


Imagine your custom component is named (class) MyCustomComponent and its package is 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 >

      

0


a source







All Articles