7

Dies ist ein Fragment, das Google Place API Integration hatte. Hier ist das erste Bild: before selecting location Überlappendes Problem in Android TextView

Nach der Auswahl eines Standorts, der wie folgt aussieht:

after selecting location from google places api

hier XML Datei ist

<?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> 

hier XML-Datei , hier habe ich kein Problem gefunden.

Java-Datei:

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. 
     } 
    } 
} 

Kann jeder vorschlagen, warum diese Überlappung geschieht?

+0

verwenden Sie ScrollView? Fügen Sie auch Ihre Aktivitätsklasse und Ihre Layoutdatei hinzu. – Zoe

+0

Überprüfen Sie, ob das Hauptlayout Ihrer Fragmente Hintergrund enthält oder nicht. –

+0

Ich verwende keine Scrollview. warten Ich werde meine XML-Datei hochladen @ Polarbear0106 –

Antwort

3

Wie Sie sagten, verwenden Sie Navigationsschublade, dann stellen Sie sicher, dass wenn Sie ein Fragment hinzufügen, sollte es durch ein anderes Fragment ersetzt werden, wenn Sie Optionen ändern. also überprüfen Sie bitte, dass Sie nicht mehrere Fragmente in einem Rahmen hinzufügen.

+2

Oh ja ich habe das gestern versucht und ich löse das Problem. danke –