Is there a way to specify the Android background like the scaleType Matrix in ImageView?

Asked 2 years ago, Updated 2 years ago, 23 views

To hide the layout located at the bottom and expand the scroll view when touching the scroll view at the top I used a method of reducing the weight. (I'm not sure if this is right because I'm a beginner.))

However, it is not a problem before the scroll view expansion, but after the expansion, the background image increased;;;;

Is there a way to specify the background image like ImageView scale Type Matrix?

android

2022-09-22 10:38

1 Answers

The android:background property in View cannot be scaleType. When configuring the layout, place the ImageView at the beginning of the layout, just as you set the image to android:background.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    android:layout_width="match_parent"
    android:layout_width="match_parent">

    <!-- ImageView to use as background -->
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/background"
        android:scaleType="matrix" />

    <!-- Views to be exposed on the background -->    
    ...
    ...

</FrameLayout>

If you cannot configure the layout of your choice in the above way, you can also create a custom view and process it by drawing your own background image. Refer to the links below for how to draw a bitmap.


2022-09-22 10:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.