2013-09-13 4 views
0

Я хотел бы показать GoogleMap в действии, например this, где красный прямоугольник будет картой, а зеленые - другими существующими макетами.display MapFragment между другими макетами в Activity

У меня уже есть MapFragment с функционированием карты, поэтому токены и другие вещи в порядке. Я попытался вставить этот фрагмент

<fragment 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    class="com.google.android.gms.maps.MapFragment" /> 

в файл макет XML деятельности (деятельность является FragmentActivity, и каждый компонент помещается внутри FrameLayout), но это дает мне ошибку при завышении раскладки.

Как я могу решить эту проблему?

+0

напишите полный файл xml здесь – Piyush

+0

Какая ошибка? Пожалуйста, опубликуйте журнал, и код и макет XML будут полезны. –

ответ

0
// try this and modify as per your requirement 
**XML** 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/lnrAddressSearch" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:padding="3dp" > 

     <EditText 
      android:id="@+id/editSearch" 
      style="?edittext_h3" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:singleLine="true" /> 

     <ImageView 
      android:id="@+id/imgSearch" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:adjustViewBounds="true" 
      android:padding="2dp" 
      android:scaleType="fitXY" 
      android:src="@drawable/ijoomer_search_icon" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="vertical" > 

     <fragment 
      android:id="@+id/maps" 
      android:name="pl.mg6.android.maps.extensions.SupportMapFragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/lnrLstMapAddress" 
     android:layout_width="match_parent" 
     android:layout_height="250dp" 
     android:orientation="vertical" > 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 

      <TextView 
       android:id="@+id/txtMapAddressHints" 
       style="?textview_h2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:padding="5dp" 
       android:text="Tap On Map To Get Address" /> 

      <ListView 
       android:id="@+id/lstMapAddress" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:cacheColorHint="#00000000" 
       android:divider="@color/blue" 
       android:dividerHeight="1dp" 
       android:smoothScrollbar="true" 
       android:visibility="gone" /> 

      <ProgressBar 
       android:id="@+id/pbrLstMapAddress" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:visibility="gone" /> 
     </RelativeLayout> 
    </LinearLayout> 

</LinearLayout> 

**Activity** 
@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.xml); 
      FragmentManager fm = getSupportFragmentManager(); 
      SupportMapFragment f = (SupportMapFragment) fm.findFragmentById(R.id.maps); 
     googleMap = f.getExtendedMap(); 

     lstMapAddress = (ListView) findViewById(R.id.lstMapAddress); 
     pbrLstMapAddress = (ProgressBar) findViewById(R.id.pbrLstMapAddress); 
     txtMapAddressHints = (TextView) findViewById(R.id.txtMapAddressHints); 
     editSearch = (EditText) findViewById(R.id.editSearch); 
     imgSearch = (ImageView) findViewById(R.id.imgSearch); 

     googleMap.setMyLocationEnabled(true); 
     googleMap.setOnMapClickListener(this); 
    } 
Смежные вопросы