Android studio Android将ImageView中的图像设置为底部中间
我想将几个不同大小的图像依次设置为ImageView。每个图像都应该位于ImageView的底部中心,但我无法使其正常工作。图像居中,但不在底部。这是我的XML,我基于线程,讨论中的ImageView位于末尾(animal)。如何将图像定位在ImageView的中心和底部Android studio Android将ImageView中的图像设置为底部中间,android-studio,android-layout,Android Studio,Android Layout,我想将几个不同大小的图像依次设置为ImageView。每个图像都应该位于ImageView的底部中心,但我无法使其正常工作。图像居中,但不在底部。这是我的XML,我基于线程,讨论中的ImageView位于末尾(animal)。如何将图像定位在ImageView的中心和底部 您的底部图像视图的布局\u宽度设置为0dp。您应该使其匹配父视图或包装\u内容 <RelativeLayout android:id="@+id/rl" android:layout_wi
您的底部图像视图的
布局\u宽度设置为0dp。
您应该使其匹配父视图
或包装\u内容
<RelativeLayout
android:id="@+id/rl"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|bottom">
<ImageView
android:id="@+id/animal"
android:layout_height="300dp"
android:layout_width="300dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
android:layout_marginTop="400dp"
android:contentDescription="@string/animal"/>
</RelativeLayout>
不幸的是,这没有帮助。我最终使用了矩阵scaletype,自己缩放并翻译了图像。