我正在尝试在另一个视图之上添加一个视图。
首先,我通过 xml 设置视图,然后我想以编程方式添加第二个视图。public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout ll = (LinearLayout) findViewById(R.id.layout);
drawView = new DrawView(this);
drawView.setBackgroundColor(Color.TRANSPARENT);
Bitmap bitmap = Bitmap.createBitmap(10, 100, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawView.draw(canvas);
drawView.setLayoutParams(new LayoutParams(800, 0, 0.18f));
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)drawView.getLayoutParams();
params.setMargins(0, 0, 0, -130);
drawView.setLayoutParams(params);
ll.addView(drawView, 2);
}
我的问题是 xml 位于我要添加的视图之上。
我怎样才能使第二个视图在顶部?