Joe*_*dev 52 android android-linearlayout
我有以下带有LinearLayout的main.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1" android:id="@+id/llid">
<TextView android:text="Client profile"
android:id="@+id/ProfileName"
android:layout_width="fill_parent"
android:textStyle="bold"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
</TextView>
<TextView android:text="Specs"
android:id="@+id/Specs"
android:layout_width="fill_parent"
android:textStyle="bold"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
</TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我在运行时通过代码向LinearLayout添加一个图像
ImageView image = new ImageView(this);
image.setImageBitmap(bmp);
LinearLayout ll = (LinearLayout) findViewById(R.id.llid);
ll.addView(image);
Run Code Online (Sandbox Code Playgroud)
但是,我想在LinearLayout中的2个TextView之间添加ImageView.我似乎无法在Android文档中找到一种方法在另一个视图之前或之后添加视图.我怎样才能做到这一点?
NB我电话
setContentView(R.layout.main);
Run Code Online (Sandbox Code Playgroud)
在我将ImageView添加到LinearLayout之前.
Idi*_*tic 11
文档声明您可以使用索引将其插入所需的位置.我看到你只使用了视图的签名,你是否尝试了带索引参数的签名?
public void addView(View child, int index)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
46860 次 |
| 最近记录: |