简体   繁体   English

Android RelativeLayout alignParentRight无法正确对齐Imageview

[英]Android RelativeLayout alignParentRight does not properly align Imageview

I am trying to place my ImageView in the bottom right corner of my display. 我试图将ImageView放在显示器的右下角。 I would like for the image to expand dynamically for different size displays. 我希望图像可以动态扩展为不同大小的显示器。

The image aligns properly when it is smaller and not set to expand, but when set it to fill_parent the image is moved to the left and no longer lines up flush with the right side of the display. 当图像较小且未设置为展开时,图像会正确对齐,但是将图像设置为fill_parent时,图像将移至左侧,不再与显示屏幕的右侧对齐。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <SurfaceView 
        android:id="@+id/surface1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        ></SurfaceView>
    <ImageView 
        android:src="@+drawable/image_1_patched" 
        android:layout_height="fill_parent" 
        android:id="@+id/imageView1" 
        android:layout_width="fill_parent"
        android:layout_alignParentRight="true"
        ></ImageView>
</RelativeLayout>

How can I make the image take up as much room as possible and remain flush to the right side of the display? 如何使图像占据尽可能多的空间并保持与显示器右侧齐平?

将您的图像视图的比例类型设置为FIT_XY。

我知道这可能无法解决问题,但是如果您希望图像停留在底部,则可能需要将此图像添加到您的imageview android:layout_alignParentBottom="true"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM