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

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -