0

我有两个图像视图,我试图将它们放入垂直线性布局中。我希望它们一个在另一个之上,但不知何故它们被水平放置。这是我的代码:

String[] portalNiz;
Uri slika;
ImageView imgLogo = new ImageView(AllDiscounts.this);
portalNiz = c.getString(1).split("\\.");
slika = Uri.parse("android.resource://rs.jedanzasve/raw/"+portalNiz[0].toLowerCase());
imgLogo.setImageURI(slika);

Uri slikaKategorije;
ImageView imgCategory = new ImageView(AllDiscounts.this);
String categoryImage = "";
if (c.getString(14).contains("lepota")) categoryImage = "lepota";
if (c.getString(14).contains("odmor")) categoryImage = "odmor";
if (c.getString(14).contains("putovanja")) categoryImage = "putovanja";
if (c.getString(14).contains("ostalo")) categoryImage = "ostalo";
if (c.getString(14).contains("proizvodi")) categoryImage = "proizvodi";
if (c.getString(14).contains("sport")) categoryImage = "sport";
if (c.getString(14).contains("hrana")) categoryImage = "hrana";
if (c.getString(14).contains("bioskopi")) categoryImage = "bioskopi";
if (c.getString(14).contains("zdravlje")) categoryImage = "zdravlje";
slikaKategorije = Uri.parse("android.resource://rs.jedanzasve/raw/"+categoryImage.toLowerCase());
imgCategory.setImageURI(slikaKategorije);

LinearLayout vertikalniSlike = new LinearLayout(AllDiscounts.this);
vertikalni.setOrientation(LinearLayout.VERTICAL);

vertikalniSlike.addView(imgLogo, new LinearLayout.LayoutParams(                     LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

vertikalniSlike.addView(imgTest, new LinearLayout.LayoutParams(                     LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

有什么想法吗?

4

1 回答 1

0

您已将 imageViews 添加到 vertikalniSlike LinearLayout 但您已将方向设置为 verticalni 布局。除非是错字。请更换:

vertikalni.setOrientation(LinearLayout.VERTICAL);

vertikalniSlike.setOrientation(LinearLayout.VERTICAL);
于 2012-12-06T22:11:22.340 回答