9 patch images not resizing in width.How to fix this? - android

I am using 9 patch images in my application.I set my 9 patch image as text background.Now it is resizing in height only.Width of the image remains the same.How to fix this?

for 9-patch images, the marked-top-edge and the marked-left-edge are the extendable edges, however the marked-bottom-edge and the marked-right-edge are which limit the contents' position.
If you want to resize the width but marked the bottom-edge nor the top-edge, the 9-patch image can't be what you want.

In a 9patch image, top edge shows the width area to be expanded. Just make sure you have only highlighted the to be expanded area on of top edge.

If your image is like the bubble below or almost similar, then the nine-patch should have the top edge specifying the width that should expand, the left edge to present the height. The bottom and right edges are for the regions within which the content should be displayed, you could experiment with that.
EDIT: As per Artoo Detoo (changed the right and the bottom edges)

Related

How do I set a imageView to scale from the top right handcorner

I have an image that I want to use as a background for an activity.
I would like to take the screens height and width from the top right hand corner of the image. For example in the image below a screen the size of the red square would display that portion of the image, where as a blue screen would display everything in the blue square.
This is similar to a background image in html with the parameters 'cover' and 'top right corner fixed'.
I would recommend using android:layout_width="1900dip" and android:layout_height="951dip" and removing some of the extra but not really import attributes you have. Dip is a better solution than dp for image sizes across android devices(since their screen sizes are all different).
For the blue screen image have its height and width match the parent which would be the relative layout which will allow for it to fill the whole page. Then the red image will overlap from the top right.
<ImageView
android:id="#+id/imageView1"
android:layout_width="1900dip"
android:layout_height="951dip"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:src="#drawable/bgnd"
/>

Android - spinner default margins

I am trying to center a spinner vertically, but it does not work since the spinner seems to have default margins that are not symmetric (the bottom margin is a bit larger than the top margin). If I set any margins to the spinner element, they are added to the default margin.
What is the recommended way to center the Spinner element vertically?
I think that bigger bottom margin exist because of the drawable(9 patch PNG) used for the spinner(you can check the drawable in the SDK):
A solution to this is to make your own spinner's drawable(9 patch PNG) that has equal space on top and at the bottom.

How to choose an image resolution to be shown fullscreen?

I have an image which is actually 393 x 21 px, which I would like to set on the bottom of my View.
The problem is that, even if i set the width and the height to fill_parent, my image stays very small in the middle of the screen bottom and on the left and the right I have an empty field.
I can resolve this by reducing the Image width size mannualy but is ther any other solution whic could set the image in fullscreen ?
Thank you.
//in your xml Image attribute as
android:scaleType="fitXY"
or //using thru programatically
imgview.setScaleType(ScaleType.FIT_XY);

android ImageView/ RelativeLayout increase size by Dragging the corner of ImageView/ RelativeLayout

i want to increase the size of ImageView/ RelativeLayout by Dragging the corner of ImageView/ RelativeLayout. But no difference in width and set it bottom. I set it by using android:layout_alignParentBottom="true" and also set image in imageview. but how to drag i don't know. Is there is any option available in Android? can any one suggest some solution for this? pls help me
you can use onTouch() for the ImageView.
Once it is touched show a small image at the edge of the imageview. And on touching that image and moving(onTouch() gives the pixel positions until you touch it) you will be getting the pixel positions. Based on that you can set the height and width of the imageview.

Influence of nine patch image non stretchable size on padding of component using it as background

I got a widget and when I use a color as a background, all the components inside have a 0 padding when I use android:layout_alignParentTop="true" (same for other sides).
But when I use a 9 patch image as the background of the parent, it seems to have a padding that is equal to the non stretchable size of the 9 patch image when I align them on their parent.
Is this normal ?
There are two main parts to a nine-patch: the stretchable areas and the content-defined areas. The top and left pixel border define the stretchable area, as I'm sure you're aware. The bottom and right, however, define the CONTENT area. If you want the padding to go away, you need to make the bottom and right bar extend all the way to the edge of the artwork (not all the way to the corner pixels, though!). Basically, the right and bottom pixel border define your padding.

Categories

Resources