0

私は 2 つの画像ビューを持っており、これを垂直線形レイアウトに入れようとしています。上下に並べたいのですが、なぜか横に配置されてしまいます。これが私のコードです:

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 に答える