【发布时间】:2016-09-21 05:36:15
【问题描述】:
是否可以使用ImageView 作为父母?我想在ImageView 上放几个TextViews,当用户放大ImageView 时,我也想放大TextViews!
注意:我制作了可缩放的 ImageView,但无法制作可缩放的 RelativeLayout...
编辑:
我的 xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<nikdan.m.metro.ZoomableImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imgMap"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Hello"
android:id="@+id/text"
android:layout_gravity="center"
android:textColor="#ff0000" />
</FrameLayout>
【问题讨论】:
-
应该可以使用
setScaleX、setScaleY、setPivotX、setPivotY`来制作可缩放视图。但我不希望 stackoverflow 上的任何人都能为您提供可以使用的代码。 -
如果 TextView 的内容没有改变,你可以通过注册一个全局预绘制监听器使图像 ZoomableImageView 成为 framelayout 的缓存视图位图来作弊