• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

How to use zoom controls on TextView in Android ?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to zoom text that is displayed at center of screen as per user choice. How can I achieve this ? Using pinch multitouch cannot be tested on emulator and I want something that I can test on Android emulator. Can I use zoom in and out controls to control only text view for my layout ? Or Can I use webview to contain a text as webview has default zoom in out buttons ? Or any better way to acheive this ?
I have also posted this on Stackoverflow here and on anddev here
 
Ranch Hand
Posts: 30
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your best and easiest way would to be as you though and create a webview to display the text and use the built in zoom, on top of this you also benefit from being able to add a find on page option, and a copy and paste feature that you cant do easily in a plain text view
 
Pritam Shah
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shawn Franks wrote:Your best and easiest way would to be as you though and create a webview to display the text and use the built in zoom, on top of this you also benefit from being able to add a find on page option, and a copy and paste feature that you cant do easily in a plain text view



Yes I had to do the same instead of other alternative of using 2D canvas for this very purpose. I faced issues when i tried to use style with the text in embedded HTML by calling loadData(), which on search I discovered some problems with using loadData() . So using loadDataWithBaseURL() with fake URL solved it. Also webview is strict in checking tags as I had to spend time for a forgotten closed tag which did not allow to use my style element.

I want to now distinguish single and multitouch events on this text element in webview, but using OnTouchListener removes my zoom controls. Does onTouchListener and Zoom Controls cannot coexist ? Any one have faced this issue ?
 
Shawn Franks
Ranch Hand
Posts: 30
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pritam Shah wrote:

Shawn Franks wrote:Your best and easiest way would to be as you though and create a webview to display the text and use the built in zoom, on top of this you also benefit from being able to add a find on page option, and a copy and paste feature that you cant do easily in a plain text view



Yes I had to do the same instead of other alternative of using 2D canvas for this very purpose. I faced issues when i tried to use style with the text in embedded HTML by calling loadData(), which on search I discovered some problems with using loadData() . So using loadDataWithBaseURL() with fake URL solved it. Also webview is strict in checking tags as I had to spend time for a forgotten closed tag which did not allow to use my style element.

I want to now distinguish single and multitouch events on this text element in webview, but using OnTouchListener removes my zoom controls. Does onTouchListener and Zoom Controls cannot coexist ? Any one have faced this issue ?



You would need to override the the normal on-touch and then have the zoom trigger when there is a touch up like say when you touch the screen then release where you touched. Also keep in mind multi touch is not supported on 99% of android phones. And yes you need to load a fake url for JavaScript to render properly when using an inputstream, or a string to load the web page.
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic