【发布时间】:2015-05-11 20:13:27
【问题描述】:
我一直在尝试将 3000 像素 x 1500 像素(大约)的大型壁纸居中,以便在加载时显示图像的中心,然后用户可以向左或向右滚动以查看其余部分。我看过几个例子,它似乎并没有帮助它总是落在图像的左侧!
我只需要另一双眼睛为我指明正确的方向。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/black">
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
>
<ImageView
android:id="@+id/imgFullscreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
提前致谢!
【问题讨论】:
-
添加图片后,您是否尝试过在 HorizontalScrollView 上调用 scrollTo(imageWidth / 2, imageHeight / 2)?
标签: android xml imageview horizontalscrollview