如何在线性布局中插入图像?

时间:2013-11-04 12:50:34

标签: android android-layout

我只想在线性布局中插入与此enter image description here类似的图像 任何人都可以帮我这个???

3 个答案:

答案 0 :(得分:1)

您可能正在寻找ImageButton,因为您的图片显示的内容与此相似。

或者,请查看ImageView

答案 1 :(得分:0)

将布局的方向设置为水平,然后在xml中添加4个图像,一个接一个地添加id,如image1,image2等,然后在onCreate中调用它们,如ImageView图像

ImageView image1 = (ImageView) findViewById(R.id.image1)

依此类推,你可以在yoru xml中设置“src”属性,或者说image1.setImageBitmap或ImageView类中可用的任何其他方法来设置你想要的图像/ res / drawable /

答案 2 :(得分:0)

您可以在水平LinearLayout中使用ImageButton 制作ImageButton @null的背景 然后把边距放在它们之间