I have a GirdView of 9 TextViews. I want to make the 9 Textviews to distribute equally in the height and the width. to fit the GridView exactly. How can I do this?
This is how I add Textviews to 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 is what I have got
I tried to use something like gridview.layoutparams
but I could not. Help me to distribute them equally like this
I have overrided the method onMeasure, but 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);
}
}