Why is my image not set to a square in my ImageView in Android?

I am trying to set an Image retrieved from my sdcard in a Square shape in an ImageView of 48 by 48dp. I have done the following coding but the Image still sets to Rectangle.Can anyone tell me step by step what to do? Bitmap bmp = BitmapFactory.decode

Using an IF statement to display views

I am create an iOS app where I need to display a different view depending on the result from an API call. At the momment I am querying the database, saving the result and then using this result to form an IF statement where I load up the correct view

How to improve the performance of drawRect?

In my app I create a grid view by subclassing UIView. If the user touches a cell of the grid, it toggles between a number of different states e.g. 'ON' or 'OFF' and changes color accordingly. So when a cell is touched I call setNeedsDisplay to refres

Have UIView drawRect occur in a background thread

I would like to have a UIView subclass that implements a method similar to setNeedsDisplay, except that redrawing (i.e., that would usually be called via drawRect:) will occur in a background thread sometime soonish, rather than at the end of the cur

Drawrect in very large uiview and memory is not enough

I am writing an app that user can draw on uiview. It works perfect if that uiview is in normal size (let say 1024 x 720). However, if I add that into uiscrollview and that dimension is 1024 x 3000, it become very slow. Also, if the height is 10000, t

drawRect: be called, only show the frame not the drawing

I have a UIControl subclass where I have drawRect implemented. I am trying to draw a rectangle inside of the drawRect method using a UIBezierPath. All the appropriate methods are being called, nothing is null and the app runs with no issues. The prob

drawRect () draws a custom shape, why not fill the color?

I 'm writing a custom shaped HUD and filling it with some color, but I can't fill the right part of my HUD. #define startX 20 #define startY 20 #define circleDiameter 60 #define PI 3.14159265358979323846 Here is the code: - (void)drawRect:(CGRect)rec

Draw a straight line between two points by dragging on IOS

I have two square images in my UIVIew. Once I drag my finger from one image to another image I want to draw a straight line between them. I have handled touchesMoved method to check when my touchLocation reaches the frame of either of the images. So

NSString font size specific to frame width

I am using drawRect for a text display, calling NSString. I am trying to implement using sizeWithFont to auto resizing font (shrinking) with default font size of 17 and using a loop to reduce the font size by 1 if it does not fit the size of width. C

UIView drawRect (): fills everything but the polygon

I need to fill my UIView in drawRect() method with 'reverted polygon' - everything in view is filled with some color except polygon itself. I've got this code to draw a simple polygon: CGContextBeginPath(context); for(int i = 0; i < corners.count; ++

How to use the drawRect method in a for loop

How can i draw a set of rectangles on a canvas Using DrawRect method? I am trying to generate a dynamic indoor map by just passing the coordinates of the blocks. I want to know.. how to use the drawRect method inside a for loop..! I made two classes

Draw with UIKit and preload

I am drawing a graph with UIKIT and I want to show before it is finished a preloader (spinning circle) Another solution should be before start drawing set the alpha of my view to 0.0 and when it's done fade it to 1.0. Someone did this before and/or k

How to darken a PNG?

I may point out that Drawing and Rendering in Objective-C is my weakness. Now, here's my problem. I want to add a 'Day/Night' feature to my game. It has got lots of objects on a map. Every object is a UIView containing some data in variables and some

Customizing the navigation bar in ios 4 does not work in ios 5

i know that this question looks the same as other around here, but none of them say anything about incompatibility between ios4 and ios5. In my app i want to customize the pattern of the navigation Bar, but my deployment target is ios4, so i am using

Problem with drawRect and a huge view

I have a view that overlays a CATiledlayer. The view is somewhere in the vicinity of 10,000x8,000 When the view is added, the device gives off memory warnings and the screen goes black. I have narrowed it down to the drawRect method and my assumption

How to draw like that in drawRect?

iPhone developing problem: I want to draw a quadrangle with the four black corners (CGPoint) of quadrangle changeable. I overrode the drawRect method but it shows only rectangle instead of quadrangle. Is that mean drawRect can only draw Rectangles wi

drawrect Vs layoutsubviews - NSView - Cocoa touch

I can't find a decent answer to explain me the difference between these 2 functions. when does every one gets called, and how does one different then the other ? for example , can't I just layout my views inside drawrect ? Thanks-layoutSubviews is ca

iPhone: drawRect called once

I'm calling setNeedsDisplayInRect from an NSTimer function every two seconds. This works perfectly, and draws a square in a random position, with a random color. However, in some circumstances I would like to draw a square x number of times in the NS

Custom drawing of alpha images

I am trying to do custom drawing of an image(with alpha) and eventually going to apply different color tints to it. Right now I am just trying to draw it correctly. This might be simple problem but the result is the ALPHA on my image is black. Image