7

Questo è un frammento con l'integrazione dell'API di Google Place. Ecco la prima immagine: before selecting location Problema di sovrapposizione in Android TextView

Dopo aver selezionato un luogo che assomiglia a questo:

after selecting location from google places api

qui è il file XML

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" 
    android:paddingLeft="10dp" 
    android:paddingRight="10dp"> 

    <in.vaksys.ezyride.utils.PercentLinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     android:orientation="horizontal"> 

     <LinearLayout 
      android:id="@+id/SearchGetFromLocation" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      app:layout_widthPercent="90%"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="FROM" 
       android:textColor="#ffffff" 
       android:textSize="12sp" /> 

      <TextView 
       android:id="@+id/SearchFromMainName" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Hyderabad" 
       android:textColor="#FFFFFF" 
       android:textSize="30sp" /> 

      <TextView 
       android:id="@+id/SearchFromSubName" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Madhapur cyber tower, Hitechcitysad" 
       android:textColor="#FFFFFF" /> 

     </LinearLayout> 

     <ImageView 
      android:id="@+id/SearchGetCurrentLocation" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:scaleType="fitEnd" 
      android:src="@drawable/ic_near_me_white_24dp" 
      app:layout_widthPercent="10%" /> 


    </in.vaksys.ezyride.utils.PercentLinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="2dp" 
     android:background="#CCC" /> 

    <in.vaksys.ezyride.utils.PercentLinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     android:orientation="horizontal"> 

     <LinearLayout 
      android:id="@+id/SearchGetToLocation" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_marginTop="10dp" 
      android:orientation="vertical" 
      app:layout_widthPercent="90%"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="TO" 
       android:textColor="#FFFFFF" 
       android:textSize="12sp" /> 

      <TextView 
       android:id="@+id/SearchToMainName" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Seconderabad" 
       android:textColor="#FFFFFF" 
       android:textSize="30sp" /> 

      <TextView 
       android:id="@+id/SearchToSubName" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:maxLines="2" 
       android:text="Seconderabad railway stasion, Secondrabad" 
       android:textColor="#FFFFFF" /> 

     </LinearLayout> 

     <ImageView 
      android:id="@+id/Search_btn_swap" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:scaleType="fitStart" 
      android:src="@drawable/swap" 
      app:layout_widthPercent="10%" /> 
    </in.vaksys.ezyride.utils.PercentLinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="2dp" 
     android:background="#CCC" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="90dp" 
     android:gravity="center" 
     android:orientation="vertical"> 

     <Button 
      android:id="@+id/btn_search_ride" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_margin="10dp" 
      android:background="@drawable/buttonshape" 
      android:text="@string/search_ride" 
      android:textColor="#FFFFFF" /> 

     <Button 
      android:id="@+id/btn_offer_ride" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_margin="10dp" 
      android:background="@drawable/buttonshape" 
      android:text="@string/offer_ride" 
      android:textColor="#FFFFFF" /> 
    </LinearLayout> 

</LinearLayout> 

qui è il file XML , qui non ho trovato nessun problema

file di Java:

private void ChooseFromLoc() { 
    AutocompleteFilter typeFilter = new AutocompleteFilter.Builder() 
      .setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS) 
      .build(); 
    try { 
     Intent intent = 
       new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY) 
//         .setBoundsBias(new LatLngBounds(new LatLng(), new LatLng())) 
          .build(getActivity()); 
      startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE_FROM); 
     } catch (GooglePlayServicesRepairableException e) { 
      GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), e.getConnectionStatusCode(), 
        0 /* requestCode */).show(); 
     } catch (GooglePlayServicesNotAvailableException e) { 
      String message = "Google Play Services is not available: " + 
        GoogleApiAvailability.getInstance().getErrorString(e.errorCode); 
      Log.e(TAG, " ajsd : " + message); 
      Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show(); 
     } 
    } 

@Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE_FROM) { 
      if (resultCode == Activity.RESULT_OK) { 
       Place place = PlaceAutocomplete.getPlace(getActivity(), data); 
      SearchFromMainName.setText(place.getName()); 
      SearchFromSubName.setText(place.getAddress()); 
      LatLng FromLatLng = place.getLatLng(); 

      FromLat = FromLatLng.latitude; 
      FromLng = FromLatLng.longitude; 


     } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) { 
      Status status = PlaceAutocomplete.getStatus(getActivity(), data); 
      Log.e(TAG, "hehh : " + status.getStatusMessage()); 

     } else if (resultCode == Activity.RESULT_CANCELED) { 
      // TODO: 23-06-2016 The user canceled the operation. 
     } 
    } 
} 

Può qualunque suggerire perché questa sovrapposizione sta accadendo?

+0

stai usando ScrollView? Aggiungi anche la tua classe di attività e il file di layout – Zoe

+0

Controlla che entrambi i frammenti del layout principale contengano o meno lo sfondo. –

+0

Non sto usando Scrollview. attendere caricherò il mio file XML @ Polarbear0106 –

risposta

3

Come hai detto che stai utilizzando il cassetto di navigazione, assicurati che se stai aggiungendo un frammento, dovrebbe essere sostituito da un altro frammento quando cambi le opzioni. quindi per favore controlla che non stai aggiungendo più frammenti in un frame.

+2

Oh sì, l'ho provato ieri e ho risolto il problema. grazie –