Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Sunday, December 27, 2015

how to right align widget in horizontal linear layout android?

how to right align widget in horizontal linear layout android?


This is the code i am using and it is not working:

                      

Answer by userSeven7s for how to right align widget in horizontal linear layout android?


Add android:gravity="right" to LinearLayout. Assuming the TextView has layout_width="wrap_content"

Answer by Sherif elKhatib for how to right align widget in horizontal linear layout android?


Do not change the gravity of the LinearLayout to "right" if you dont want everything to be to the right

Try:

  1. Change TextView's width to fill_parent
  2. Change TextView's gravity to right

        

Answer by nurne for how to right align widget in horizontal linear layout android?


You should use a RelativeLayout and just drag them until it looks good :)

          

Answer by alcsan for how to right align widget in horizontal linear layout android?


Try to add empty View inside horizontal LinearLayout before element that you want to see right, e.g.:

                                            

Answer by AZone for how to right align widget in horizontal linear layout android?


With Linear Layout

                    

enter image description here

with FrameLayout

                    

with RelativeLayout

                    

Answer by Shubham for how to right align widget in horizontal linear layout android?


Try This..

                          

Answer by Saad Mahmud for how to right align widget in horizontal linear layout android?


setting the view's layout_weight="1" would do the trick.!

          

Answer by mrvinent for how to right align widget in horizontal linear layout android?


Try to change the layout_width to android:layout_width="match_parent" because gravity:"right" aligns the text inside the layout_width, and if you choose wrap content it does not have where to go, but if you choose match parent it can go to the right.

Answer by Hiren Patel for how to right align widget in horizontal linear layout android?


I have done it by easiest way:

Just take one RelativeLayout and put your child view in it, which you want to place at right side.

                                                                                

Hope it will help you.

Answer by Weekend for how to right align widget in horizontal linear layout android?


As a supplement to alcsan's answer, you can use Space since API 14 (Android 4.0 ICE_CREAM_SANDWICH), document here.

Space is a lightweight View subclass that may be used to create gaps between components in general purpose layouts.

                        

For apps that supporting API levels under 14, there is an android.support.v4.widget.Space since Android Support Library r22.1.0.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.