1

I'd like to have LinearLayout with background set to some drawable.

Can I round it's corners somehow as it could be done with shape and gradient?

Main problem is I need to be repeating the bitmap so it matches view's size

Community
  • 1
  • 1
Jacek Kwiecień
  • 12,397
  • 20
  • 85
  • 157

2 Answers2

1

Try this and add it as a bacground to your Xml item :

<?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >
          <solid android:color="#dadada"/> 
                 <corners
                       android:topLeftRadius="13dip"
                       android:topRightRadius="13dip"
                       android:bottomLeftRadius="13dip"
                       android:bottomRightRadius="13dip"/>
         <stroke android:width="1dip" android:color="#ff000000"/>
   </shape>

Edit : you can define an ImageView in your LinearLayout then you can set it's background to your rounded shape

ImageView IV=(ImageView)findViewById(R.id.imageView);
IV.setBackgroundResource(R.drawable.round_border); 
Arash GM
  • 10,316
  • 6
  • 58
  • 76
0

This is workaround which works perfectly as long you have single color background #000000 should be the background color:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <bitmap android:src="@drawable/action_bar_background" android:tileMode="repeat"/>        
    </item>    
    <item>
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <stroke
                android:width="5dp"
                android:color="#000000" />

            <solid android:color="#00000000"/>

            <corners android:radius="7dp" >
            </corners>
        </shape>
    </item>    
        <item>
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <stroke
                android:width="5dp"
                android:color="#000000" />

            <solid android:color="#00000000"/>

        </shape>
    </item>
</layer-list>
Jacek Kwiecień
  • 12,397
  • 20
  • 85
  • 157