The best way is to create a rounded corener button with a background that has a repeating bitmap.

I just would like to know the best way to achieve this. I have a button with rounded corners, but I would also like the button background to be a texture that has been tiled.

I would be grateful for any help

+3


source to share


2 answers


Thank you for your suggestions but they don't work :( I ended up doing the inevitable and creating a custom view where I imported the GradientDrawable from my resources where I defined rounded corners etc. and then I also imported mine " texture "as a BitmapDrawable and used by PorterDuffXfermode to mask it. It would be nice to create a shape and then apply to that shape :(.



+1


source


For rounded corners, check this:

http://nishantvnair.wordpress.com/2010/11/09/customize-button-in-android/

to add an image background, just add it to the resource



<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <shape android:shape="rectangle" android:padding="10dp">
    <corners android:bottomRightRadius="30dp"
             android:bottomLeftRadius="30dp" 
             android:topLeftRadius="30dp"
             android:topRightRadius="30dp" />
    </shape>
  </item>
  <item>
    <bitmap android:src="@drawable/yourfilename" 
            android:tileMode="repeat" />
  </item>
 </layer-list>

      

from: set background image and xml resource

+1


source







All Articles