android - How to add weights to Textview in Gridview programmatically -


this question has answer here:

i have girdview of 9 textviews. want make 9 textviews distribute equally in height , width. fit gridview exactly. how can this?

this how add textviews gridview

string[] arrayempty = new string[] {"", "", "", "", "", "", "", "", ""}; arraylist<string> list = new arraylist<string>(arrays.aslist(arrayempty)); gridview.setadapter(new arrayadapter<string>(this,r.layout.list_item,list)); 

this have got enter image description here

i tried use gridview.layoutparams not. me distribute them equally enter image description here

i have overrided method onmeasure, did not work

import android.content.context; import android.util.attributeset; import android.widget.gridview;  public class mygridview extends gridview { public mygridview(context context) {     super(context); }  public mygridview(context context, attributeset attrs) {     super(context, attrs); }  public mygridview(context context, attributeset attrs, int defstyle) {     super(context, attrs, defstyle); }  @override public void onmeasure(int widthmeasurespec, int heightmeasurespec) {     super.onmeasure(widthmeasurespec, widthmeasurespec); }  } 

check this

git hub.

it's open source project in git hub.here can find layout , source code sudoku.i hope you.


Comments