Search code examples
androidandroid-layoutandroid-linearlayoutandroid-imageview

android scale ImageView parent clip scaled imageView


i have imageView inside LinearLayout the imageView scaled by

 setScaleX(e);
 setScaleY(e);

e is float value

and the xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="wrap_content"
android:clipChildren="false"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal">




    <test.blabla.com.app.scledImageView
        android:layout_width="30dp"
        android:layout_height="30dp"
         android:id="@+id/scaled"
        android:src="@drawable/emoji_1f3b0_64"
        android:layout_gravity="center_vertical|center_horizontal" />




  </LinearLayout>

now this image before i scale ImageView

enter image description here

after scale imageView

enter image description here

the parent LinearLayout not effected by scale and its height and width still same i try use this for linearLayout while scale

parent.invalidate();

also i tried

parent. postInvalidate();

still same problem


Solution

  • i solve it by scale width and height now parent width and height changed when its child size changed parent.invalidate();