Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

getting width of View when making custom renderer for Android TableLayout

$
0
0

Hi, I'm making a custom renderer for Android TableLayout.
What I want to do is that making TextView's backgound which has width size proportional to TextView's width size.

Here is the sample code.

FrameLayout frame = new FrameLayout(Context);
TextView textView = new TextView(Context);
Android.Views.View background = new Android.Views.View(Context);

textView.Text = "HI";
frame.AddView(textView, LayoutParams.MatchParent, LayoutParams.WrapContent);

background.SetBackgroundResource(Resource.Drawable.Border);
frame.AddView(background, LayoutParams.MatchParent, LayoutParams.WrapContent);

Here, I want to change the width size(LayoutParams.MatchParent in frame.AddView(background, LayoutParams.MatchParent, LayoutParams.WrapContent)) to certain value that proportional to width size of textView.

eg. if an width of textView is 10, I want to set the width of background as 4.

But if I try to getting width value of textView by textView.Width, the value is 0.

So, I don't know how to get the value of width of View, in this case TextView.

please give me some idea.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>