[mono-android] How to use "dip" or "dp" layout dimension for LayoutParams width and height?
g pe
gpe.mpro at gmail.com
Thu Jun 28 08:08:47 UTC 2012
It may not be the solution but I use the Canvas.Dpi value I have in the
argument of OnDraw(Canvas) of a View and use it to convert from my units.
Changing the Dpi is not the solution anyway as it would be a big job/mess
for the entire system. Just scale with the actual Dpi of the device. I
guess you can find this value from somewhere else if you are not overriding
the View.OnDraw
On Wed, Jun 27, 2012 at 9:18 PM, Sellec <echelonww at gmail.com> wrote:
> Sorry about my question, but i dont see any information in google.
> How can i set width like "30dp" for dynamically created label in my custom
> view?
> For example:
> var label1 = new TextView(this.Context);
> label1.LayoutParameters = new
> ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, 30);
> label1.Gravity = GravityFlags.CenterVertical;
> label1.SetText("test", TextView.BufferType.Normal);
> this.AddView(label1);
> But this height of 30 is set with normal pixels and looks different on
> emulator and real device (screen dimensions is different). And i dont see
> any way to set a type of pixels for layoutparams. How can i do this?
>
>
> --
> View this message in context:
> http://mono-for-android.1047100.n5.nabble.com/How-to-use-dip-or-dp-layout-dimension-for-LayoutParams-width-and-height-tp5710626.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120628/ecbf15d6/attachment.html>
More information about the Monodroid
mailing list