Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report for Bug 27937 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
My application is like a table view which displays data in a table format. All I have made is kept a class extending from FrameLayout as my base class. Inside that I have loaded a custom scrollviewer which is extended from FrameLayout as well. The scrollviewer has a contentView to display the contents which is also derived from FrameLayout. Now I have inserted few FrameLayouts inside my ContentView which acts as rows. Each row has few cells which is a custom class derived from ViewGroup. I have loaded a text view inside each cell and when setting the center alignment for textView(GravityFlags.Center) the alignment is not working.
To replicate it in a simple sample I have tried loading three FrameLayouts one inside the other in the layout file. Then programatically created a Row which contains only cell(extended from ViewGroup) in it. Now if I set Gravity as GravityFlags.Center for the TextView loaded inside my cell, it does nothing. I expect the text to be centerAligned but it does not happens. I have attached the simple sample which replicated me the issue. I hope it will be fixed soon.
Created attachment 10286 [details]
Sample to replicate CenterAlignment not working when inserting view programatically.
The attached sample replicates the reported issue.
I believe that GravityFlags.Center is working as documented, e.g.:
The above stackoverflow result suggests that you should instead use android:layout_gravity:
I think am pretty clear about this.
1) gravity is the way the text will align itself in the TextView.
2) layout_gravity is the way the TextView will align itself in its parent.
And my requirement is the text in the textView should be center aliged.
I have manually arranged the textview inside the parent specifying its width and height. so I have acheived the second statement. My problem is the first statement. I need the text inside the textview to be center aligned.
If I change the sample doing every thing in xml, the text is center aligned. But it is not when doing it programatically. So this is surely an issue.
And moreover am unaware about whether android:layout_gravity programatically. It will be helpful if you share how it can be done if it is possible.