I am constructing a View through some methods and at the end I am getting a View object which I then add to a LinearLayout. The problem isn't in the last class before I add it to the Linearlayout I want to add another view programmatically. When I try this I don't get any error but the view is somehow invisible. Here is my code:
View newView = new ListItemView().getView(viewList.get(i));
if (AppData.postDimRead) {
if (dimList.contains(viewList.get(i))) {
try {
Log.e("found", "dimView");
View viewMask = new View(AppData.context);
RelativeLayout.LayoutParams maskParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
viewMask.setBackgroundColor(Color.parseColor("#000000"));
RelativeLayout rootView = (RelativeLayout) newView.findViewById(R.id.rootView);
rootView.addView(viewMask, maskParams);
rootView.requestLayout();
} catch (Exception e) {
e.printStackTrace();
}
}
}
layout.addView(newView);
layout.requestLayout();