在RelativeLayout中缩放的ImageView放置
我需要在 RelativeLayout
中放置三个元素:
- 右侧
ImageView
中的缩放图像,顶部和底部边距 TextEdit
位于左上角LinearLayout
位于其余空间(标题下方和图像左侧)
当图像在 ImageView
中缩放时会出现问题。考虑到边距,我希望它适合整个父母的身高。均匀缩放以适应父级的高度后,我希望 ImageView 包裹图像的宽度。但结果是 ImageView
中有一些未填充的水平空间。
该问题看起来与此处解决的问题类似。但就我而言,所有使用 android:adjustViewBounds
和 android:scaleTypes
的测试都不起作用。我认为由于边距和相对布局的使用而存在问题。
以下是我的 xml 文件的摘录:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@id/albums_slideshow"
android:adjustViewBounds="true"
android:layout_marginTop="71.33dp"
android:layout_marginBottom="88.67dp"
android:scaleType="centerInside"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/music_img_album_noimage"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/music_module_screen_title_margin_left"
android:layout_marginTop="@dimen/music_module_screen_title_margin_top"
android:text="@string/music_string"
style="@style/ScreenTitleFont"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignTop="@id/albums_slideshow"
android:layout_toLeftOf="@id/albums_slideshow">
...
</LinearLayout>
</RelativeLayout>
有人遇到过这个问题并找到答案吗?
I need to place three elements inside RelativeLayout
:
- scaled image in
ImageView
on the right side with the top and bottom margins TextEdit
in the left top cornerLinearLayout
in the rest of the space (below the title and to the left of the image)
The problem happens when the image is scaled in ImageView
. I want it fits the entire parent's height considering margins. After scaling uniformly to fit the parent's height I want ImageView
wraps the image's width. But as the result there are some unfilled horizontal spaces in ImageView
.
The problem looks similar to one solved here. But in my case all tests with android:adjustViewBounds
and android:scaleTypes
didn't work. I suppose there is a problem because of margins and RelativeLayout use.
Here is the extract from my xml file:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@id/albums_slideshow"
android:adjustViewBounds="true"
android:layout_marginTop="71.33dp"
android:layout_marginBottom="88.67dp"
android:scaleType="centerInside"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/music_img_album_noimage"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/music_module_screen_title_margin_left"
android:layout_marginTop="@dimen/music_module_screen_title_margin_top"
android:text="@string/music_string"
style="@style/ScreenTitleFont"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignTop="@id/albums_slideshow"
android:layout_toLeftOf="@id/albums_slideshow">
...
</LinearLayout>
</RelativeLayout>
Has anyone met this problem and found the answer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我想出的
这是 xml
让我知道改进
this is what i have come up with
and this is the xml
let me know for improvements