hide a portion of button under textedit - android

I am trying to achieve exactly something like this
- a text view on left and a button to its right
- Button should be wrap_text
- textedit should occupy the remaining space
If you carefully see the image in the image the buttons left curved border are hiding under the text view.
I am using relative layout to adjust the button height according to this
How to get a button's height to match another element's height?
But I am unable to hide the left portion of the button.

Actually the Button isn't hidden under the EditText.
They used custom background for that button, which is 9 patch png image. You can achieve this by providing your 9 patch images for both EditText and Button with 0 margin between them.
Here is a nice tutorial about using 9 patch png.
Another post to consider is Buttons with (niceley) stretched background.

add android:layout_marginLeft="-10dp" to the button

Related

android imageview auto scaled without overlap other view

I have a linear layout(mLL) that fit the whole screen.
Within it, there are 3 things.
That is a textview contains a mulit line string.
It is followed by a imageview. The imageview fit the remain area of screen (problem here).
That I added a horizontal menubar (radiogroup with some image buttons) and aligned it to the bottom of linear layout(mLL).
The result is the radiogroup button show on top of the image.
What I hope is, the imageview fit itself to occupied the whole screen, but left sufficient space for textview and a horizontal radiogroup button.
I know I can use program code to scale the image, but I wonder if there are some attributes or correct xml layout that can intuitively create above arrangement? I mean, the arrangement of some text, followed by picture, and then a menubar is so common that should have a better way to implement it.
P.S. I tried to add the menubar before the imageview. Consequently, the imageview shows on top of menubar, i.e. menubar is partially hidden.
P.S2. The menubar need to tough the bottom of screen. So, it should be added to relative to mLL.

Move an element in relative layout to absolute edge of the screen

Is it possible to move a button or any other element in relative layout to the absolute edge of the sreen? If I drag a certain element to the edge of the layout, eclipse will automatically place it a few dp away from the edge. It'll basically just create a small space between a button and the end of the creen. Is it possible to bypass that?
I know buttons aren't meant to be that close to the edge of the screen anyway, but I need it for a certain thing.
The normal button has a little padding by default, because the buttons backgroundimage is a 9-patch image with padding left, right and on bottom. That's why you see the space between button and screen.
To solve this you can use a custom button. For example change the backgroundimage of button like this android:background="#drawable/image".

Resize Image within a Button

Is there any way of resizing an image in a button? The image source is from the drawables folder. I want to have the following layout for the button.
I know that we can use the android:drawableLeft XML tag for the button, but the image is crossing the boundary of the button and thus getting cut off on all sides.
I want my entire image to be in within "Image here" slot from the above depicted layout. How can I achieve this?
If you are using a default button, use the default padding (don't set the padding values) and the image should not cross the boundary.
Alternatively for finer control you can place an ImageView and TextView within a layout (e.g. LinearLayout) and set the layout's style="#android:style/Widget.Button".

How to 9-patch so icon always stick with centered text

Basically, I wanted to have a button where text and icon stay in the middle of the button at all times. The Button has match_parent width and center gravity. I tried to use drawableLeft but that put icon on the left most of the Button and not next to the text.
So I'm trying to create 9-patch image as shown in the image above. Basically, I want all the text to stay in blue box with the cyan rounded rectangle (icon) next to it. The stretchable area is in red. However I just can't make it as the content area always overlap the icon.
Is this possible with 9-patch? Or should I wrap Layout around the TextView and use that as a button instead?
By the way, the included image is just to show what I plan to do. The actual image will be in other colors and without all the red.
When you create a nine-patch image, you put some black lines on the right and bottom of the image. These lines define the region that will be use to place the content inside of your image.
Here is an example :
It will look like this :

How to remove the android Button Background margins?

I'm new to Android dev, I'm trying sth simple: I want to place a set of 3 buttons horizontally in a line, each with its own background PNG image. So I create a linear layout (horiz) and put three Button elements, each with a weight of 1, and set each button's Background property to some png file. The buttons' width/height is set to wrap_content.
But what I get is that the png does not cover the entire button horizontal area. Instead, the background image is scaled down and keeps some sort of margin from the button view outline as shown in the visual designer. This also shows up in the emu. I tried forcing 0 in the layout's padding/margin - nada.
any idea on how to actually get the background image of a button to cover the button's background??
tnx
I believe you would need to make a new 9-patch, as that small margin is saved into the button image itself.
Try negative values for the buttons layout_margin.

Categories

Resources