这是代码片段:
//The view is created manually
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
myListView = (ListView) inflater.inflate(R.layout.my_lv_layout, null, false);
... //the ListView is prepared (that part of my program works)
RelativeLayout.LayoutParams myListViewParams =
new RelativeLayout.LayoutParams(width, height);
myListViewParams.addRule(RelativeLayout.ABOVE, R.id.button_at_the_bottom_of_the_relative_layout);
//the listView is added here, but it is not above the button, but in the upper
//left corner of the screen (the above-rule is simply ignored)
myRelativeLayout.addView(myListView, myListViewParams);
(但规则RelativeLayout.ALIGN_PARENT_RIGHT
在这里确实有效)
在文件my_lv_layout.xml
中除了宽度和高度属性之外没有定义任何规则。
我怎么解决这个问题?