can't add border on map fragment android

一个人想着一个人 提交于 2020-01-16 19:16:08

问题


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 ?


回答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>


来源:https://stackoverflow.com/questions/24266908/cant-add-border-on-map-fragment-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!