0

I get an issue when I try to add border on fragment, this seems not to work ... This is my fragment xml, but if I added on other layout like Linear or Relative Layout, this works..

<fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_below="@+id/include1"
        android:background="@drawable/border_bottom"
         />

and border_bottom.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item> 
    <shape android:shape="rectangle">
      <solid android:color="#FF0000" /> 
    </shape>
  </item>   
    <item android:bottom="5dp" >  
     <shape android:shape="rectangle"> 
      <solid android:color="#000000" />
    </shape>
   </item>    
 </layer-list> 

How do I fix it ?

tckmn
  • 57,719
  • 27
  • 114
  • 156
bukanamay
  • 577
  • 5
  • 11
  • 26
  • It would be better if you place the fragment inside a layout with some padding [approx 2dp] to make the border visible. Apply the background drawable to this outer layout. – AabidMulani Jun 17 '14 at 14:59

1 Answers1

1

As an example of the answer, below is the code. Wrap the fragment map with a linearlayout, and put the border in the linear layout. And in your fragment map, add margin

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/border_bottom" >
    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_margin="2dp"
        android:layout_height="120dp"
        android:layout_below="@+id/include1"
        android:background="@drawable/border_bottom"
     />
</LinearLayout>
Elye
  • 53,639
  • 54
  • 212
  • 474