Android - scaling a viewgroup (layout) at runtime -



Android - scaling a viewgroup (layout) at runtime -

i've got bunch of tiles create single image, rendered on request (by what's portion of total image visible on screen). composite image larger screen. each tile positioned tightly next neighbors create illusion of single image (the single image, if not tiled, big , have oom errors).

these imageviews within framelayout, positioned top/leftmargin.

targetting api 2.2 / sdk 8

i'm trying scale total image in response user events (button presses, pinch, etc).

apparently setscale isn't available until api 11. tried using canvas.scale in ondraw of framelayout setwillnotdraw(false), , ondraw beingness called, no scaling beingness applied (i assume because layout doesn't have graphic information? had assumed it'd render it's children well, guess not unless i'm doing wrong here also).

i guess iterate through each tile , scale independently, need reposition each 1 well, each time.

i have think there's way scale parent view (viewgroup?) of children scaled (like every other language responsible managing gui). missing?

thanks

for reference, approach mentioned above (using ondraw of parent viewgroup) in fact work. had been using canvas.save() before transformation , canvas.restore() after (based on examples), incorrect.

the next generic subclass of framelayout scale it's children

package com.whatever.layouts; import android.content.context; import android.graphics.canvas; import android.widget.framelayout; public class scalingframelayout extends framelayout { private float scale = 1; public scalingframelayout(context context) { super(context); setwillnotdraw(false); } public void setscale(float factor){ scale = factor; invalidate(); } public float getscale(){ homecoming scale; } @override public void ondraw(canvas canvas){ canvas.scale(scale, scale); super.ondraw(canvas); } }

android

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -