Custom view and horizontal scrolling

961 views
Skip to first unread message

yasir perwez

unread,
Apr 26, 2011, 3:03:50 PM4/26/11
to android-...@googlegroups.com
I have a custom view derived from View class. Where I am drawing a graph using Canvas and I have implemented onDraw. This view is horizontally bigger then screen.
I want to make is scrollable horizontally. The custom take sevaral argument it it constructor. I tried various option

Like make layout xml and

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<HorizontalScrollView android:id="@+id/scroll" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:fillViewport="true">

            <com.yasir.canvasTest.GraphView android:layout_width="fill_parent"
              android:layout_height="fill_parent"/>

</HorizontalScrollView >
    
</LinearLayout>

then

in onCreate of Activity

setContentView(R.layout.horscroll);

Question :- How will I specify argument to the contructor of my custom view.

I also tried creating HorizontalScrollView and adding custom view using HorizontalScrollView.addview() the application did not crash but
my custom view is not display. It onDraw never gets called.

Please suggest me how to solve this issue.

--
Yasir Perwez


Dianne Hackborn

unread,
Apr 26, 2011, 8:17:59 PM4/26/11
to android-...@googlegroups.com
You need to make the view that is a child of the scroll view actually larger in size than the scroll view so there is something to scroll.

Further questions on this would best be asked on android-developers or StackOverflow.



--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Reply all
Reply to author
Forward
0 new messages