android - Center ListView horizontally -


It's as easy as it sounds, as list of inventory will not be self-centered (or its In-the-content is not - & lt ;? xml version = "1.0" encoding = "UTF-8"?> Android; layout_height = "wrap_content" android: background = "@ android: color / holo_blue_dark"> -> -> gt; Android: layout_height = "wrap_content" android: overScrollMode = "never" Android: scrollbar = "none" Android: Divider = "@ Null" Android: listSelector = "@Android: Color / Transparent" Android: persistentDrawingCache = "Scroll | Animation" Android: Background = "@Android: Color / holo_green_dark" /> & Lt; -! & Lt; / RelativeLayout & gt; - & gt; & Lt; / LinearLayout & gt;

This list item has an item layout:

   & Lt; TextView Android: id = "@ + id / btn_text" android: layout_width = "wrap_content" android: layout_height = "wrap_content" style = "@ style / custom_btn_name" /> & Lt; TextView Android: AD = "@ + ID / BTN_ count" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" style = "@ style / custom_btn_count" /> & Lt; / RelativeLayout & gt;   

I have tried everything (including layout to simplify max), but it still will not go.

It is fun that the first relative layout clock_container - the center attraction of the same, due to the parent's linear letter android: gravity = "center_horizontal" . Why not see the list?

Added later: inspired by the answer to FOliveira , I have done some investigation and found that: everything works fine, mother In the linear layout android: gravity = "center_horizontal" and your children are respectfully left for children of ListView to combine that ListView their android: layout_width = "wrap_content" attribute, despite all the possible width.

Nobody knows why he is?

p>

After keeping the relative layout as the main parent, CENTER_IN_PARENT Set the attribute to true.

The mistake you make is that you make the linear gravity baby horizontally for the center, which is correct, but this option only affects the affected children only with a relative layout.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -