I have an ImageView
sandwhiched between two LinearLayout
. The ImageView
has zoom capability which allows me to zoom in and out of the image - this means the image can grow up to the entire size of the screen (match_parent).
If I load a very tall (height) image, the image overlaps the two LinearLayout
which is NOT ok when arriving at the screen but is ok if user has decided to zoom in later. Is there a way to "limit" the height of the ImageView on initialization but also allow it to grow the entire screen size?
The following is an example of a "tall" image being loaded incorrectly as it covers the top LinearLayout
text:
And this is how I would like the image to be loaded, with the ability to grow to the size of the previous image:
This is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBgBlackTintDarker"
android:orientation="vertical"
android:paddingTop="20dp">
<!-- Title at the top -->
<LinearLayout
android:id="@+id/big_display_title_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<!-- Title stuff here-->
</LinearLayout>
<!-- Middle custom ImageView with ability to zoom-->
<com.sometimestwo.moxie.ZoomieView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/full_displayer_image_zoomie_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
<!-- Bottom toolbar-->
<LinearLayout
android:id="@+id/big_display_snack_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/transparent"
android:orientation="horizontal">
<!-- Bottom toolbar stuff-->
</LinearLayout>
</RelativeLayout>
EDIT: Here's a GIF to illustrate what I am experiencing:
The Image zooms in and out as desired but I need the image to fit in between the title and the bottom toolbar at initialization so it does not cover anything (until the user decides to zoom).
You should sandwich the ImageView
between two LinearLayout
s in parent RelativeLayout
. Change your code as below:
<!-- Middle custom ImageView with ability to zoom-->
<com.sometimestwo.moxie.ZoomieView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/full_displayer_image_zoomie_view"
android:layout_below="@id/big_display_title_container"
android:layout_above="@id/big_display_snack_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
You can try to use a ConstraintLayout.
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp">
<LinearLayout
android:id="@+id/big_display_title_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<!-- Title stuff here-->
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/big_display_snack_bar_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/big_display_title_container"/>
<LinearLayout
android:id="@+id/big_display_snack_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/transparent"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent">
</LinearLayout>
</android.support.constraint.ConstraintLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.