raduq
Newbie
Hello!
I have just started about two weeks ago to develop Android applications and also, just started working with XML. I think I understood most of the things in XML and the way it influences the application, but I can't understand the difference between android:layout_gravity and android:gravity, applied for example on a button.
I have tried to align a button to the center and used this code:
and it worked properly. But also, I have tried the one where "android:layout_gravity" is replaced with the simple "android:gravity" with the same center option, but it does not work.
I have read in the small pop-up box with the options that appears when I type in the code that the "layout_gravity" is "Standard gravity constant that a child can supply to its parent."
So, the child in my situation is the <Button /> and the parent is the <LinearLayout />, right?
If that's right, it means that the layout_gravity:center in the <Button />tag influences the <LinearLayout /> tag? I'm almost sure that's not the deal, but what's the thing with CHILD and PARENT? I got it a bit mixed up.. as I think you can see already.
Any help is very much appreciated!
I have just started about two weeks ago to develop Android applications and also, just started working with XML. I think I understood most of the things in XML and the way it influences the application, but I can't understand the difference between android:layout_gravity and android:gravity, applied for example on a button.
I have tried to align a button to the center and used this code:
Code:
<Button
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log in"
android:layout_gravity="center" />
I have read in the small pop-up box with the options that appears when I type in the code that the "layout_gravity" is "Standard gravity constant that a child can supply to its parent."
So, the child in my situation is the <Button /> and the parent is the <LinearLayout />, right?
If that's right, it means that the layout_gravity:center in the <Button />tag influences the <LinearLayout /> tag? I'm almost sure that's not the deal, but what's the thing with CHILD and PARENT? I got it a bit mixed up.. as I think you can see already.
Any help is very much appreciated!