I have a textview inside a grid layout and I want to change the size of grid cells according to the text area of the text view. If the word size is 5, then the grid size will be calculated accordingly. I am adding both the textview and the grid dynamically. I used the below code for this text area calculation,
text[i].setText(String.valueOf(finallist.get(i)));
text[i].measure(0, 0);
int widths = text[i].getMeasuredWidth();
params.width=widths;
text[i].setLayoutParams(params);
text[i].setTextSize(10);
where 'params' is the layout params for the textview. When I run this code, I am getting output as shown below.
Here I am getting extra spaces in between the grids no matter the textview size is wrapped. Instead I wanted the grid layout to occupy the area if it's available. I wanted the output like this,
I wanted equal spacing between the grids. How can I achieve this DYNAMICALLY .Also I am implementing drag and drop here. I am new to this. Please help. Thanks in advance.