[英]Unable to align ImageView to bottom of RelativeLayout
I've read several tutorials on how to do this, but for whatever reason, my image won't budge from the center of the screen. 我已经阅读了一些有关如何执行此操作的教程,但是无论出于何种原因,我的图像都不会偏离屏幕中心。 The ninjas image is 1080x517px
忍者图片为1080x517px
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1"
android:background="@color/white">
<ImageView
android:id="@+id/ninjas"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/ninjas"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
From what I can tell, this is correct. 据我所知,这是正确的。 Any suggestions?
有什么建议么? Thanks in advance
提前致谢
You make the image fill the parent currently. 您使图像当前填充父级。 Change
更改
android:layout_width="fill_parent"
android:layout_height="fill_parent"
to 至
android:layout_width="wrap_content"
android:layout_height="wrap_content"
try this 尝试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<ImageView
android:id="@+id/ninjas"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
Try changing 尝试改变
<ImageView
android:id="@+id/ninjas"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/ninjas"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
to 至
<ImageView
android:id="@+id/ninjas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ninjas"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
At present your ImageView
is occupying all the space in its parent. 目前,您的
ImageView
占据了其父级的所有空间。 After changing layout_width
and layout_height
to wrap_content
it will only occupy as much space as size of @drawable/ninjas
将
layout_width
和layout_height
更改为wrap_content
,它将仅占用@drawable/ninjas
大小的空间
// Try this way,hope this will help you to solve your problem...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:gravity="bottom|right"
android:padding="5dp">
<ImageView
android:id="@+id/ninjas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ninjas"
android:adjustViewBounds="true"/>
</LinearLayout
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.