I have in Android/Java/Eclipse a Flag Guess Game: appear a name of country and below 3 or 6 or 9 flags (depend on settings) in 1 or 2 or 3 rows respecively to, choose the flag for the country name...well something wrong exist and flags appear some very big and others very-very small... eg rather appear 3 in the same row normally...

flags 99% have width 480px and height 235-333px ... Nepal is 400x480px...etc what is the trick to insert 3 flags in a row (table) in about each in 150dp x 100dp WxH...?

      // get a reference to the LayoutInflater service
      LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      // add 3, 6, or 9 answer Buttons based on the value of guessRows
      for (int row = 0; row < guessRows; row++) 
         TableRow currentTableRow = getTableRow(row);

         // place Buttons in currentTableRow
         for (int column = 0; column < 3; column++) 
            // inflate guess_button.xml to create new Button
                 ImageView newGuessButton = (ImageView) inflater.inflate(R.layout.guess_flag, null);
            // get country name and set it as newGuessButton's text
            String fileName = fileNameList.get((row * 3) + column);
            setFlag(fileName, newGuessButton);  

            // register answerButtonListener to respond to button clicks
         } // end for
      } // end for

      // randomly replace one Button with the correct answer
      int row = random.nextInt(guessRows); // pick random row
      int column = random.nextInt(3); // pick random column
      TableRow randomTableRow = getTableRow(row); // get the TableRow
      //String countryName = getCountryName(correctAnswer);

      setFlag(correctAnswer, ((ImageView)randomTableRow.getChildAt(column)));
   } // end method loadNextFlag

   private void setFlag(String nextImageName, ImageView newGuessButton)
   // extract the region from the next image's name
   String region = nextImageName.substring(0, nextImageName.indexOf('-'));

   // use AssetManager to load next image from assets folder
   AssetManager assets = getAssets(); // get app's AssetManager
   InputStream stream; // used to read in flag images

      // get an InputStream to the asset representing the next flag
      stream = assets.open(region + "/" + nextImageName + ".png");

      // load the asset as a Drawable and display on the flagImageView
      Drawable flag = Drawable.createFromStream(stream, nextImageName);
   } // end try
   catch (IOException e)  
      Log.e(TAG, "Error loading " + nextImageName, e);
   } // end catch


   <?xml version="1.0" encoding="UTF-8"?> 
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"

<?xml version="1.0" encoding="utf-8"?>
   <dimen name="title_size">25sp</dimen>
   <dimen name="flag_width">227dp</dimen>
   <dimen name="flag_height">150dp</dimen>
   <dimen name="answer_size">40sp</dimen>
   <dimen name="text_size">20sp</dimen>
   <dimen name="flag_height2">90dp</dimen>
   <dimen name="flag_width2">131dp</dimen>


see attachment my code result...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.