Android 我们可以将视图添加到布局的子级吗?

Android 我们可以将视图添加到布局的子级吗?,android,Android,我的xml中有一个线性布局 在运行时,我在这个线性布局中添加了一个填充父对象的图像视图。现在我想在这个imageview上添加一个按钮。是否可以将此按钮添加到此图像视图的中心?我们可以在任何其他视图的子视图中添加视图 请建议我该怎么做。使用相对布局,而不是线性布局: <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView and

我的xml中有一个线性布局

在运行时,我在这个线性布局中添加了一个填充父对象的图像视图。现在我想在这个imageview上添加一个按钮。是否可以将此按钮添加到此图像视图的中心?我们可以在任何其他视图的子视图中添加视图


请建议我该怎么做。

使用
相对布局,而不是
线性布局

<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
     <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" />
     <Button android:id="@_id/the_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:visibility="gone"/>
</RelativeLayout>

FrameLayout可以将多个视图堆叠在一起,先生,我在代码中使用的是简单的xml。只有线性布局。在运行时,我首先创建图像视图,它填充这个线性布局。现在我想在这个图像视图的中心添加一个按钮。请告诉我该怎么做。我有很大的申请。这就是我一直坚持的概念…
RelativeLayout
也很有帮助您尝试过addView(查看子项,int索引)吗?
Button b = (Button) findViewById(R.id.the_button);
b.setVisibility(View.VISIBLE);