java - 在 ImageView 中对齐位图图像 - CS50 Pokedex Android
问题描述
我一直在研究 CS50,现在我正在跟踪 android。我几乎完成了我的 PSet Pokedex,但有小事困扰着我。
我试图在 ImageView 上对齐位图图像,但我做不到。请你帮助我好吗?我尝试了“scaletype”、“layout_gravitiy”等。但它似乎不起作用。我希望图像正好在说明下方,说明这应该由 java 代码更改。 请在此处查看当前视图
<?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>
解决方案
推荐阅读
- android - Timber 中有没有办法在日志中显示父方法名称 android
- javascript - FirebaseError:[code=resource-exhausted]:写入流已用尽最大允许排队写入
- javascript - 为什么按住一个键会写一个字母,口吃一秒钟,然后继续向该键发送垃圾邮件?
- python - 如何更新字典以添加到 Python 中的列表
- r - Rmarkdown knit 给 pdf 提供了错误的情节。ggplot2 单独呈现正确的
- javascript - 有人可以解释 JavaScript 中 debounce 函数中的“this”吗?
- java - 尝试使用模拟来验证方法的使用时出现 NullPointerException
- python - 如何使python命令运行2.7版本和python3运行3.8.5版本
- c++ - 您不能像从特定命名空间调用函数一样从特定命名空间调用预处理器宏吗?
- reactjs - 在 React 中将 props 绑定到父状态