Java 对齐ImageView内的位图图像-CS50 Pokedex Android
我一直在研究CS50,现在我正在跟踪android。我几乎完成了我的PSet Pokedex,但小事情困扰着我 我正在尝试将位图图像对齐到ImageView的顶部,但我无法做到这一点。你能帮帮我吗?我试过“scaletype”、“layou_gravity”等,但似乎不起作用。我希望图像刚好位于描述的下方,说明这应该由java代码更改。Java 对齐ImageView内的位图图像-CS50 Pokedex Android,java,android,xml,android-studio,cs50,Java,Android,Xml,Android Studio,Cs50,我一直在研究CS50,现在我正在跟踪android。我几乎完成了我的PSet Pokedex,但小事情困扰着我 我正在尝试将位图图像对齐到ImageView的顶部,但我无法做到这一点。你能帮帮我吗?我试过“scaletype”、“layou_gravity”等,但似乎不起作用。我希望图像刚好位于描述的下方,说明这应该由java代码更改。 欢迎来到StackOverFlow 如果没有特殊要求,则无需在ImageView内部使用match\u parent。您可以进行以下调整- <Linea
欢迎来到StackOverFlow 如果没有特殊要求,则无需在ImageView内部使用
match\u parent
。您可以进行以下调整-
<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>
..............
快乐编码 欢迎来到StackOverFlow 如果没有特殊要求,则无需在ImageView内部使用
match\u parent
。您可以进行以下调整-
<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>
..............
快乐编码 对不起。我在火炉里烤雪。我发现,实际上源图像是一个罪魁祸首。图像大小不包裹内容,但在内容周围有额外的空间。这就是为什么当它被放大时,文本和图像之间有空间 对不起。我在火炉里烤雪。我发现,实际上源图像是一个罪魁祸首。图像大小不包裹内容,但在内容周围有额外的空间。这就是为什么当它被放大时,文本和图像之间有空间 使用相对布局重叠视图将比例类型更改为fitxy,然后您可以根据需要调整填充顶部fitxy会弄乱图像的比例,并且似乎不起作用。我也无法使用相对布局解决问题。请发送您将在ImageView中设置的图像使用相对布局重叠视图将比例类型更改为fitxy,然后您可以根据需要调整填充顶部fitxy会弄乱图像的比例,并且似乎不起作用。我也无法用相对布局解决问题。请发送您将在ImageView中设置的图像谢谢提示。但源图像太小了,我想让它尽可能大。谢谢你的提示。但源图像太小了,我想让它尽可能大。