Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overlapping Issue in Android TextView

This is one fragment which had Google Place API Integration. Here is the first image: before selecting location

After selecting a place that looks like this:

after selecting location from google places api

here is XML File

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

here is XML File , in here I didn't found any problem.

Java file :

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

Can any suggest why this overlapping is happening?

like image 426
Harsh Dalwadi Avatar asked Jul 07 '16 09:07

Harsh Dalwadi


1 Answers

As you said you are using navigation drawer then make sure that if you are adding an fragment then it should be replace by another fragment when you change options . so please check it out that you are not adding multiple fragments in one frame .

like image 140
Vishal Avatar answered Nov 15 '22 13:11

Vishal