In my project, I need to dynamically draw lines of a text view according to the received data in order to show it. To align them correctly, I used Table Row n xml and named it in java code. Now, in their LayoutParam I gave MATCH_PARENT, but it wraps the text according to the length of the received data. Now I want to fix the width of the fields for the table view. I am doing this whole process in the postExecute method. In this method, I used the setWidth function to set it according to the width of the title bar element. Here, Sno is a view, and size is an array containing the width of all headerRow elements.
Sno.setTag(patient); Sno.setWidth(size[0]);
But this did not solve this problem, when I tried getWidth to see its width, it showed its value 0. Then I tried to set this width using LinearLayout.LinearParams
LinearLayout.LayoutParams params_sno = new LinearLayout.LayoutParams(size[0], LinearLayout.LayoutParams.MATCH_PARENT); Sno.setLayoutParams(params_sno);
but still no benefit, secondaly, if I remove MATCH_PARENT from the width of the LayoutParams, its width has increased from the width of the title bar element. fields without data are invisible.
source share