java - android:layout_gravity doesn't work as expected -


I have a simple LinearLayout with a TextView and an ImageView. I want to combine text in the TextView to the right, but the results show that the text was aligned to the left, is there something wrong in my layout xml? Thank you.

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Android: layout_heid = "wrap_content" Android: background = "# E8E3E4" "& Gt; & Lt; LinearLayout Android: Orientation = "Horizontal" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" & gt; & Lt; Android: text-style = "bold" Android: background = "# ff0000" Android: textcolor = "# 121222" Android: textView = "260dp" Android: layout_height = "wrap_content" android: text = "more comment" Android: Layout_gravity = "right" /> & Lt; Android: layout_width = "50dp" Android: layout_height = "wrap_content" Android: src = "@ drawable / arrow_right" Android: layout_gravity = "center" Android: scaleType = "centerInside" /> & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt;  

Thank you, Michael, but the pattern you mentioned is not working.

I tried to use the resettlelight, but it still gave me the result: more comments (icon)

What do I expect more comments (icon)

< P> Relative layout XML is there anything wrong in it?

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; RelativeLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" & gt; & Lt; Android: layout_height = "wrap_content" android: text = "more comment" Android: text-style = "bold" Android: background = "# ff0000": TextView Android: id = "@ + id / label" Android: layout_width = "260dp" "Android: textColor =" # 121222 "Android: layout_gravity =" right "/> & Lt; Android: layout_width = "50dp" Android: layout_height = "wrap_content" android: src = "@ drawable / arrow_right" Android: layout_gravity = "center" Android: scaleType = "centerInside" Android: layout_toRightOf = "@ id / label" & Gt; & Lt; / RelativeLayout & gt;  

After working in Michael's comment, I have XML, I hope the output should be:

  Left  < / Pre> 

but the actual output is:

  left right  

then the solution does not work for me.

  & lt; LinearLayout Android: Orientation = "Horizontal" Android: layout_width = "fill_parent" android: layout_height = "wrap_content" & gt; & Lt; TextView android: layout_width = "wrap_content" Android: layout_height = "wrap_content" android: layout_gravity = "right" Android: layout_weight = "1.0" Android: text = "right" /> & Lt; TextView android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_gravity = "left" android: text = "left" / & gt; & Lt; / LinearLayout & gt;  

Linear layout with a horizontal orientation not supported correctly Do / left gravity can get you an alternative solution.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -