1.
RelativeLayout downloadRelativeLayout = new RelativeLayout(context); downloadRelativeLayout.setBackgroundColor(Color.WHITE); downloadRelativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); downloadListView = new ListView(context); downloadListView.setPadding(10, 10, 10, 10); downloadListView.setDivider(getResources().getDrawable(R.drawable.line)); LayoutParams listViewLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); downloadRelativeLayout.addView(downloadListView, listViewLayout);