android - Use SeekBar onProgressChanged for custom view -


i have created reusable custom component (a custom view canvas drawing bitmap), it's slider can used (volume control/rating systems). problem need monitor it's progress, seekbar onprogresschanged.

i have no clue implement this. can't use seekbar , try re use this, need use custom component..

would have idea on this?

my layout follows:

enter image description here need monitor movement of sliding image , try calculate sort of progress or there easier way?

any input on appreciated, it's first effort @ custom components

edit

here how xml layout looks:

   <relativelayout         android:layout_width="match_parent"         android:layout_height="200dp"         android:id = "@+id/slider1"         android:layout_alignparenttop="true">          <com.cs.customslider.slider.app.sliderview             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:id="@+id/sliderview"             sliderview:diagonalslide="false"             sliderview:translateaxisx="false"/>         <imageview             android:id="@+id/slider_frame"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/slider_frame"             android:layout_centerhorizontal="true">         </imageview>  </relativelayout> 

disclaimer: won't work 100% intend, should started.

your customview extends view. use getleft() position of view. use getparent() viewgroup holds view, linear or relative layout , it's width.

now have rough idea of view's position in parent, farther right, more "progress." subtract width of customview width of parentview because measuring theleft side, , left side of customview can never touch rightside of parent view.

hope helps there...

    view view = ...;      //position of view;     int pos = view.getleft();      //number of pixels view can slide across screen.     viewgroup vg = (viewgroup) view.getparent();     int width = vg.getmeasuredwidth();      //right position view can reach,     int available_width = width - view.getmeasuredwidth();      float progress = ((float) pos) / available_width; 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -