0

I have a simple problem.

This is my XML

<LinearLayout
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="45px" <!-- for testing only -->
    android:orientation="horizontal" >

<ImageView
    android:id="@+id/bed_bugs"
    android:layout_width="0dip"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:adjustViewBounds="true"
    android:background="@drawable/button_tab"
    android:src="@drawable/some_title" />

</LinearLayout>

And this is my Drawable button_tab

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <bitmap
             android:tileMode="repeat"
             android:src="@drawable/tile_test"/>
    </item>
</layer-list>

tile_test is a simple image image of tile_test

My question is, how can I scale the tiled image?

This is what I have - current

This is what I need - requirement

2 Answers 2

0

i think its imposable in xml, i created what i need in code 1) get bitmap 2) resize bitmap 3) create drawable with tileMode ( from resized pic ofc ) 4) set background to you image with created drawable

its simple but not in xml (

0

I did it just making the source image 1/2 it's size, so the pattern becomes smaller 1:2 scale. I think this is the best way as you use just one pattern I suppose. Original Scaled 1:2

But..., it needs also a way to scale it, as image resolution will be always bad...

The best way to use the method is through a "pixel-art" image, so it will not be shown blurred. I followed this way in the app I made: Implementation in my app

1
  • (please if someones see this upvote me, StackOverflow not allows me to publish answers anymore...) Oct 18, 2022 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.