I inflated guess_flag.xml with an ImageView but not get good sized images


  1. lse123

    lse123 Well-Known Member

    I inflated guess_flag.xml with an ImageView but not get good sized images, how fix?[HIGH] 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);
    newGuessButton.setAdjustViewBounds(false);
    // 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
    newGuessButton.setOnClickListener(guessButtonListener);
    currentTableRow.addView(newGuessButton);
    } // end for
    } // end for[/HIGH]
    HTML:
    1.  
    2.  
    3. R.layout.guess_flag.xml
    4. <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    5.   android:id="@+id/newGuessButton"
    6.  
    7.      android:adjustViewBounds="false"
    8.      android:layout_width="@dimen/flag_width2"
    9.      android:layout_height="@dimen/flag_height2"
    10.      android:contentDescription="@string/imgToGuess"></ImageView>
    11.  
    12.  
    13. dimen.xml
    14. <?xml version="1.0" encoding="utf-8"?>
    15. <resources>
    16.    <dimen name="title_size">25sp</dimen>
    17.    <dimen name="flag_width">227dp</dimen>
    18.    <dimen name="flag_height">150dp</dimen>
    19.    <dimen name="answer_size">40sp</dimen>
    20.    <dimen name="text_size">20sp</dimen>
    21.    <dimen name="flag_height2">90dp</dimen>
    22.    <dimen name="flag_width2">131dp</dimen>
    23. </resources>
    24.  
    25.  
    26.  

    Advertisement
  2. lse123

    lse123 Well-Known Member

    see screenshot

    Attached Files:

Share This Page