I need to prepare FrameLayout (containing ImageView much bigger than screen size and other ImageViews - overlays), which must be simultaneously:
- rotatable by any angle
- scrollable both horizontally and vertically
For scrolling I use the solution presented here: https://stackoverflow.com/a/6716638/2274709
My code is as follows:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<com.chrosciu.konferencja.VScroll android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/vScroll">
<com.chrosciu.konferencja.HScroll android:id="@+id/hScroll"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/planView"
android:src="@drawable/map"
android:scaleType="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</FrameLayout>
</com.chrosciu.konferencja.HScroll>
</com.chrosciu.konferencja.VScroll>
</RelativeLayout>
MainActivity.java:
...
private void rotate(float angle) {
FrameLayout frameLayout = (FrameLayout)findViewById(R.id.frameLayout);
frameLayout.setRotation(angle);
}
....
However this causes some troubles: FrameLayout is cropped after rotation, I cannot reach the corners even by scrolling it manually
Even when I set minHeight and minWidth of FrameLayout to enlarge it after rotation, the result is still not satisfactory:
- once I enlarge dimensions of FrameLayout I am not able to shrink it back,
- I have to manually scroll the layout to fit enlarged area
This does not seem to be fanciful task. Am I going the right way? Are there another methods to achieve this?