Bulk Emailing

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, 9 August 2010

Overlay on Android Layout

Posted on 01:07 by Unknown
This will help you to create custom Layout and add Overlay on a LinearLayout. The concept can be reused on other Layout classes i.e. RelativeLayout, FrameLayout etc.

I have added a popup Selection Palette, containing "Map Pin" and "List" icons. You can minimize the popup by clicking on the section in Green on the left side bottom corner of the screen.
 

How can I do that-
You need to follow 4 steps-
1. Override LinearLayout
Create a Class MyLinearLayout.java which should overwrite LinearLayout

2. Drawing
You need to overwrite dispatchDraw(Canvas canvas) method. It gives control to the whole screen. Make sure you set android:layout_height="fill_parent" for the associated layout definition in XML. You can draw anything and anywhere on the canvas. dispatchDraw(Canvas canvas) gets called only after underlying views are drawn, so whatever you draw comes in the foreground.
 
3. Event Handling
You need to overwrite dispatchTouchEvent(MotionEvent e) method. onTouchEvent(MotionEvent e) doesn't work. Make sure you don't pass click event controls when user clicks on your specific drawing region.

4. Using your custom Layout on XML
You can now use your custom Layout class in Layout XML files (define your class name with package, see below example) -


You can download complete source code from here.
Email ThisBlogThis!Share to XShare to Facebook
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • CityWeather
    Update: Release 1.1 has been uploaded. It will now provide weekly forecast of your selected cities. Download   CityWeather is an Android...

Blog Archive

  • ►  2013 (6)
    • ►  September (2)
    • ►  May (1)
    • ►  April (1)
    • ►  February (1)
    • ►  January (1)
  • ►  2012 (4)
    • ►  July (2)
    • ►  March (1)
    • ►  January (1)
  • ►  2011 (11)
    • ►  November (1)
    • ►  October (2)
    • ►  August (1)
    • ►  June (1)
    • ►  April (2)
    • ►  March (3)
    • ►  January (1)
  • ▼  2010 (27)
    • ►  December (2)
    • ►  November (3)
    • ►  September (2)
    • ▼  August (4)
      • Overlay on Android Layout
      • Overlay on Android ListView
      • Region Handling in Android Canvas
      • Image Geo Tagging for Android
    • ►  July (4)
    • ►  June (7)
    • ►  May (5)
Powered by Blogger.

About Me

Unknown
View my complete profile