【发布时间】:2017-06-07 14:01:44
【问题描述】:
您好,我有一个 ImageView(background),其高度应与屏幕高度相对应,另一方面,宽度应保持不变。
之前是这样的
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/songDetails_songImage"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:contentDescription="@string/songDetails_cd_songCover"
app:srcCompat="@drawable/default_song_cover" />
</HorizontalScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
...
这很好 - 图像视图占据整个背景,用户可以向右或向左滚动以查看整个图像。
我的目标是为滚动设置动画,为此我需要摆脱水平视图(以防止用户滚动),但每当我将 HorizontalScrollView 更改为 Frame/Relative 布局(宽度设置为 wrap_content)时图像视图按比例缩小以适合屏幕。
有没有办法保持 imageView 的宽度不变(高度与屏幕的高度匹配),使其保持比设备屏幕大?(不裁剪)
然后我可以使用自定义动画向右滚动。
我已经查看了类似的问题,但我找不到任何适用于这种情况的方法。
【问题讨论】:
标签: android android-layout android-imageview horizontalscrollview