android - Setting width of a view as a fraction of the width of screen -


can set width of view fraction of screen's width? if yes, how?

here's code

var screenwidth = (int)(resources.displaymetrics.widthpixels / resources.displaymetrics.density); double prc = 0.35;  double w = prc * screenwidth;  // 35 percent of screen linearlayout.layoutparams viewparams = new linearlayout.layoutparams(convert.toint32(w), viewgroup.layoutparams.matchparent); layout.layoutparameters = viewparams; 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -