In my android app, I want to create a linear layout horizontally and add a textview on the left side and a progress bar on right right side, I want the textview to wrap content for width. And the progress bar should (for width) take up the remaining space horizontally on the screen.
This is my code:
LinearLayout.LayoutParams percentWidth = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
LinearLayout percentLayout = new LinearLayout(this);
percentLayout.setOrientation(LinearLayout.HORIZONTAL);
percentLayout.setLayoutParams(percentWidth);
textview = new TextView(this);
textview.setText(String.format("Tasks Completed: %d%%", personobj.percentage));
percentLayout.addView(textview);
ProgressBar checklistprogress = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
checklistprogress.setProgress(personobj.percentage);
percentLayout.addView(checklistprogress);
LocationLayout.addView(percentLayout);
However this is not working, the progress bar width is not expanding fully. It's only about a centimeter width.
Does anyone know how to do this?
Thanks.