android - Center A View using Java in AndroidStudio -


how can center view created in java? have following code in oncreate method of activity:

    gridlayout gridlayout = new gridlayout(this);     gridlayout.setcolumncount(5);     gridlayout.setrowcount(5);     (int = 0; < 25; i++) {         imageview imageview = new imageview(this);         gridlayout.addview(imageview, i);     }     setcontentview(gridlayout); 

now, i'd gridlayout containing imageviews vertically centered on screen when program runs. how can this?

setlayoutparams(layoutparams);  

set layout params gridview , imageviews. able check views clearly.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -