我遇到图像问题。我怎样才能把图像放在另一个人面前。 问题是我在代码中创建图像。所以我不能在布局中更改顺序。ImageView,如何设置图像看起来在另一个图像的前面?
0
A
回答
0
0
可以使用的RelativeLayout:
RelativeLayout rv = (RelativeLayout) findViewById(R.id.my_ph);
RelativeLayout.LayoutParams params;
ImageButton im1 = new ImageButton(this);
im1.setBackgroundResource(R.drawable.lamp);
im1.setId(i);
im1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
TextView tx = (TextView) findViewById(R.id.textView1);
tx.setText("lamp #" + v.getId());
}
});
params = new RelativeLayout.LayoutParams(40, 40);
params.leftMargin = x;
params.topMargin = y;
rv.addView(im1, params);
XML布局:
<RelativeLayout
android:id="@+id/my_ph"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/map" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_below="@+id/image"
android:layout_alignParentLeft="true">
</TextView>
</RelativeLayout>
0
如果要创建通过代码的图像,你可以使用的LayoutParams给第二图像负LEFTMARGIN。
RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams
(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
imageParams.leftMargin = -20; // change this value
imageParams.addRule(RelativeLayout.RIGHT_OF,image1.getId());
image2.setLayoutParams(imageParams);
这将强制第一个图像上的第二个图像。通过更改左边距,您可以决定第二张图像在第一张图像上的移动量。
相关问题
- 1. 在imageview中设置图像,使其看起来像一个进度条
- 2. 动态设置imageView在另一个图像上查看
- 3. 图像看起来像一个破碎的图像
- 4. 在imageview上拖动图像或在android上设置另一个图像
- 5. 内容如何看起来像图像
- 6. 将另一幅图像放在另一幅图像的前面
- 7. 在imageView中设置图像
- 8. 如何从另一个Imageview复制一个ImageView的图像
- 9. 如何在ImageView中设置图像?
- 10. 如何在Android ImageView中设置图像
- 11. 如何显示一个图像查看另一个图像?
- 12. Imageview看起来像mapview
- 13. 在另一个布局上为ImageView设置图像
- 14. 在imageview中设置图库的图像
- 15. Android - 从一个图像到另一个图像的imageview
- 16. 如何将图像从一个ImageView截取到另一个ImageView
- 17. 如何设置图像.BMP到ImageView的
- 18. 设置窗体看起来像这样的图像?
- 19. ImageView图像看起来像素化和低质量
- 20. 图像大小压缩。无法使imageView看起来像Photoshop图像
- 21. 如何让我的jlabel图标看起来像桌面图标?
- 22. 如何将一个UIImageView的图像设置为另一个UIImageview的图像
- 23. 我们如何设计看起来手绘的图像/图形?
- 24. 从url设置imageview图像
- 25. Android ImageView设置图像源
- 26. 如何使TextView看起来像一个设置的PreferenceCategory标头
- 27. 保存图像视图上有另一个蒙面的ImageView?
- 28. 使图像视图看起来在每个设备相同
- 29. 如何让UIPickerView看起来像图像中的那个?
- 30. 在另一个div图像上设置div图像asp.net
您可以为此使用框架布局。第2张图像将显示在第1张的顶部。 – sUndeep 2015-02-10 09:54:05