Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] java – Align Bitmap Image inside ImageView – CS50 Pokedex Android

Posted on November 14, 2022

Solution 1 :

Welcome to StackOverFlow !

If there is no special requirement than no need to use match_parent inside ImageView. You can do following adjustment-

<LinearLayout xmlns_android="http://schemas.android.com/apk/res/android"
    xmlns_app="http://schemas.android.com/apk/res-auto"
    xmlns_tools="http://schemas.android.com/tools"
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_orientation="vertical"
    tools_context=".PokemonActivity">

    ..............

    <ImageView
        android_id="@+id/pokemon_avatar"
        android_layout_gravity="center"
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"/>

</LinearLayout>

Happy coding !

Solution 2 :

sorry. I was roasting snow in a furnace. I found out that actually source image is one to blame. Image size does not wrap the content but it has extra space around content. This is the reason when it is enlarged, there is space between text and image. Image

Problem :

I have been working on CS50 and now I am tracking android. I almost finished my PSet Pokedex, but small thing is bothering me.

I am trying to align bitmap image on top of ImageView, but I could not do it. Could you please help me? I tried “scaletype”, “layout_gravitiy” etc. But it does not seem to work. I want image to be just below description stating that this should be changed by the java code.
Please see current view here

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns_android="http://schemas.android.com/apk/res/android"
    xmlns_app="http://schemas.android.com/apk/res-auto"
    xmlns_tools="http://schemas.android.com/tools"
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_orientation="vertical"
    tools_context=".PokemonActivity">

    <TextView
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_id="@+id/pokemon_name"
        android_textAlignment="center"
        android_textSize="18dp"
        android_textStyle="bold"
        android_paddingTop="10dp" />
    <TextView
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_id="@+id/pokemon_number"
        android_textAlignment="center"
        android_textSize="16dp"
        android_paddingTop="5dp" />
    <TextView
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_id="@+id/pokemon_type1"
        android_textAlignment="center"
        android_textSize="16dp"
        android_paddingTop="5dp" />
    <TextView
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_id="@+id/pokemon_type2"
        android_textAlignment="center"
        android_textSize="16dp"
        android_paddingTop="5dp" />

    <Button
        android_id="@+id/pokemon_button_catch"
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_textAlignment="center"
        android_paddingTop="5dp"
        android_textSize="24dp"
        android_onClick="toggleCatch"
        />

    <TextView
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_id="@+id/pokemon_description"
        android_textAlignment="center"
        android_textSize="16dp"
        android_textStyle="bold|italic"
        android_paddingTop="50dp"
        android_text="This is testing something, this should changed by the java code."/>

    <ImageView
        android_id="@+id/pokemon_avatar"
        android_layout_width="match_parent"
        android_layout_height="match_parent"/>

</LinearLayout>

Comments

Comment posted by Shubham Gupta

Use Relative layout to overlap views

Comment posted by Code Demon

Change scale type to fitxy then you can adjust the padding top as per your needs

READ  [ANSWERED] android studio - Flutter errors Exceptions customTrace and fromJSON
Powered by Inline Related Posts

Comment posted by enszrlu

fitxy is messing the scale of the image and seems to does not work. I could not solve with relative layout also.

Comment posted by Abdur Rehman

also send image that you are going to set in imageview

Comment posted by enszrlu

Thanks for the tip. But source image is soo small that I want to make it big as possible.

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress