What's the exact size of paddingLeft of checkbox? - android

I wonder what's the exact size of the paddingLeft of checkbox, the padding from the beginning of the layout to the beginning of the checkbox, just like the picture shows.
I guess it's almost 7dp or 8dp.
So where can I get the exact number of it?
Sorry I cannot insert the picture in the body.
The picture is here.
paddingLeft picture

I don't really understand what you want, is it calculating the distance from the checkbox to the text or what? instead of using padding, you can use:
android: layout_margin: "8dp"
hopefully this can help you

Related

How to center a multiline text view with the smallest width necessary?

I would like to have my 2-line text view in android-xml centered horizontally with the smallest width necessary. At the moment it's like the first line is completely filled and the second with the rest of the words.
Does anyone know how to achieve that both lines are filled kind of equally? Below are 2 images, the first showing the default multi-line text view, the second what I would like to achieve. As you can see, the second image requires much less width than the first and is more in the center of the view.
Thanks in advance!
Try setting android:breakStrategy attribute of textView to balanced
android:breakStrategy="balanced"
Add this line to your textView's xml code, this will balance the lines.

Is there a way to set min-height of textview wrt to lines?

Is there a way to set the min-height of a text view wrt to the number of lines. Let's say if I know that the text size is 20dp and the min-height should be such that it's equivalent to 3 lines of text then what should it be. Could be done by using line height or some hacks but I wanted to know if there's a legit way to achieve this?
You should add TextView height to wrap_content and ellipsize to end.
android:minLines="3"

TextView onDraw - Drawing Lines

I would like to draw vertical lines between Numbers/Letters in my TextView. So it should look similar to
A|B|C|D
without the use of the | character and use drawLine() instead.
I am trying to do it using the width of the TextView and assuming the centre of each character will find itself at , 1/8, 3/8, 5/8, 7/8 of the TextView width for this example. However the lines dont line up as they should.
Not sure whats not working, help appreciated.
I am trying to do it using the width of the TextView and assuming the centre of each character will find itself at , 1/8, 3/8, 5/8, 7/8 of the TextView width for this example.
That's your problem. For starters, you haven't specified that you're using a mono-spaced font. If you're not, then the letters won't be evenly distributed. Even if you are using a mono-spaced font, likely the padding at the beginning (and possibly end) of the TextView are going to offset things. I can't remember exactly how TextView measures things, but I suspect looking at actual left padding value would be a good start to find the left padding. If you want to use this with a variable width font, you'll want to use something like Paint.measureText to measure the width of the characters.
Once you have all that, you can add the width of the character(s) to the left padding to find the position to place each line.

Android - Button height not decreasing to wrap text

I set the button's height via XML. Suppose it to be X
<Button
android:layout_height="wrap_contnet"
android:textSize = " <X> dp"
....
....
/>
If I set X to greater than 15 dp, the button's height grows to fit the text. But when I set it to something lower like 2dp, the button's height doesn't change and I can see a thick border around it as shown below:-
As shown above, text size is so small but still height doesn't decrease!
How can I force it to be of appropriate height?
Thanx in advance!
Font size does not depend on button height. If you set it too small to fit the text, you will get the result you observe
EDIT
wrap_content would usually do the trick, however Button class sets some layout parameters like margin, background so it takes more space. You may get rid of Button and use i.e. TextView class, styled by hand to match your design. onClickListener will work perfectly fine with it and you will get result you want and full control over your button
EDIT 2
As this is bit related - there's AutoFitTextView widget on Github that deals with automatic text size scalling: https://github.com/grantland/android-autofittextview
Just Set android:minHeight="xxdp"

Proper layout for EditText Boxes

I was wondering about what is wrong with my layout.
Here is a screenshot.
Problem being that the text is being cut off in edit text boxes.
I suppose there is something wrong with the text's XY co-ordinates at the time of typing in those edit text boxes; the cursor blinks fine to me.
Here is the pastebin of my XML layout (not putting it here because its quite lengthy).
Any advice will be appreciated. Thanks
The text size of the text inside edittext is large for hardcoded 30dp height of edittext. You can either set edittext height to wrapcontent or reduce the textsize of edittext (10-14sp)so that it fits inside.
It is advised by android to set minimum height of clickable area to at least 48dp.
http://developer.android.com/design/style/metrics-grids.html

Categories

Resources