What is use of Android:height attribute when we already have Android:layout_height attribute?? I have tried using it in TextView and EditText ,, have made No usefull difference
Asked
Active
Viewed 1,258 times
1
-
Well, usually layout_* means that this will be applied on itself from the parent and direct attributes affects the childs in the node – Marcos Vasconcelos Aug 06 '13 at 22:23
2 Answers
0
According to the Docs
Makes the TextView be exactly this many pixels tall.
I'm guessing its something old and is only if you want to dictate, as it says, a specific number of pixels. I wouldn't suggest using it but stick with android:layout_height

codeMagic
- 44,549
- 13
- 77
- 93
-
1Yes I read that Document. Then I tried using it. The Code crashed in the absence of [layout_height] (API 11) , and if we use both [layout_height] and [height] together it doesn't care what [height] says – Prince Aug 06 '13 at 22:30
-
To be honest, I have never used it and I doubt anyone has for a long time. As Commonsware said, it was probably needed in the early days but now you must use `android:layout_height` which can do the same thing but more – codeMagic Aug 06 '13 at 22:40
-
@codeMagic you can always set `android:layout_height="wrap_content"` and then set your desired size in `android:height="wrap_content` – Martin Dec 22 '13 at 10:16
-
@Martin I'm not sure what difference that is going to make. It seems redundant since the docs say "You could get the same effect by specifying this number in the layout parameters." – codeMagic Dec 22 '13 at 17:25
-
@codeMagic dam there is a typo. Of course you can't set `android:height="wrap_content"` — And the difference is: you have to set the layout_height but **don't** you have to set the height. Then the object calculates it's hight automaticly. Which is the better idea in most cases anyway. – Martin Dec 28 '13 at 13:58
0
It all depend on the ViewGroup used but generally if your use android:layout_height="wrap_content"
then android:height
becomes the actual size.
For details: https://stackoverflow.com/a/20728106/341091
Note that if you don't set android:height
the view will calculate the size itself. Which is right thing to do most of the time.