I added a View to layout programmatically to draw a horizontal line. 
Below is java code.
  // I want to add a view to ll
  LinearLayout ll = (LinearLayout)findViewById(R.id.main);
  LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
  View view = new View(this);
  ll.addView(view);
  view.setLayoutParams(params);
  // this method does not work.
  view.setBackgroundDrawable(getResources().getDrawable(R.drawable.division_line));
my division_line.xml in /drawable is:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke android:color="#800400"
            android:width="2dp"/>
</shape>
I tried to apply division_line.xml to View but it doesn't work. What method should I use? 
 
    