Android 如何以编程方式将imageView添加到framelayout中
您好,在我的xml文件中,我有一个包含textView和框架布局的relativeLayout:Android 如何以编程方式将imageView添加到framelayout中,android,android-layout,Android,Android Layout,您好,在我的xml文件中,我有一个包含textView和框架布局的relativeLayout: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="20dp"> <EditText android:id="@+id/id_send
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
<EditText
android:id="@+id/id_send_EditText"
android:layout_width="match_parent"
android:layout_height="45dp"
android:hint="@string/enter_text"
android:textColorHint="@color/com_facebook_button_background_color_disabled"
android:paddingRight="40dp"
android:layout_alignParentBottom="true"
android:isScrollContainer="true"/>
<FrameLayout
android:id="@+id/fl_pubCreate"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
</RelativeLayout>
简单添加
flayout.addView(imgMedia);
这样做
flayout.addView(imgMedia);
只需调用flayout.addView(imgMedia);你用谷歌搜索过这个问题吗?这是如何在布局中添加视图的基础之一。您只需调用
flayout.addView(imgMedia)
。唯一需要注意的是设置正确的layuotpams,这取决于您希望图像的显示方式。从查看队列:我可以请求您在您的答案周围添加更多的上下文吗。只有代码的答案很难理解。如果你能在你的文章中添加更多的信息,这将有助于询问者和未来的读者。
flayout.addView(imgMedia);