BottomSheet не отображается за изображением ViewView с помощью onTouchListener после касания экрана - PullRequest
0 голосов
/ 14 марта 2019

У меня есть изображение, которое имеет setOntouchlistener.при касании изображения отображается информация о сенсорной области на расширенном нижнем листе.

Когда я запускаю приложение, все отображается изначально, как и ожидалось, я вижу изображение нижней таблицы внизу экрана., который отображается поверх imageView.

Однако, как только я касаюсь экрана, вид изображения затем отображается над нижней таблицей, поэтому я не вижу эту нижнюю страницу.

когда я закомментирую setOnTouchListener для просмотра изображений, это больше не проблема.Я также попытался использовать фрагменты для этого, что привело к точно такой же проблеме.Может ли кто-нибудь предложить некоторые решения для этого ??

Я попытался добавить сенсорный список для LinearLayout bottomSheet и просмотра изображений в нижней таблице.с возвращением false, но не решает проблему.

Ниже приведены выдержки из важных частей кода.

  <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="vertical"
android:padding="@dimen/activity_margin"

app:behavior_hideable="true"

app:behavior_peekHeight="50dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_gravity="center_vertical"
    android:weightSum="3">


</LinearLayout>


<ImageView
    android:id="@+id/fragmentImageView"
    android:layout_width="match_parent"
    android:layout_height="173dp"
    android:src="@android:drawable/btn_star_big_on" />

<TextView
    android:id="@+id/locationInfoTextView"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_marginTop="173dp"
    android:text="Smellybottom" />

 </LinearLayout>

setOntouchListener в моей деятельности

  photoview2.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            touchX = (int) event.getX();
            touchY = (int) event.getY();


            ///##frag//LocationInfoFragment fragobject2 = (LocationInfoFragment) getSupportFragmentManager().findFragmentById(R.id.infoFragment) ;
            ///##frag//LinearLayout infoFragementLayout = (LinearLayout) findViewById(R.id.infoFragmentLayout);
            sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            ImageView fragmentImageView = (ImageView) findViewById(R.id.fragmentImageView);
            TextView locationInfoTextView = (TextView)findViewById(R.id.locationInfoTextView);
            ///##frag//infoFragementLayout.setVisibility(View.INVISIBLE);
            for (InfoLocationInformation locationArrayVariable : mInfoLocationInformations) {
                if(touchX > locationArrayVariable.getXy().get(0) & touchX < locationArrayVariable.getXy().get(2) & touchY > locationArrayVariable.getXy().get(1) & touchY < locationArrayVariable.getXy().get(3)){
                    //Log.e(TAG, "Location information for " +  locationArrayVariable.getName()  );


                    if(locationArrayVariable.getType()<1 && infoButton.getBackgroundTintList().getDefaultColor()==-49023+100){

                        locationInfoTextView.setText(locationArrayVariable.getText());

                        sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);




                    }else if(locationArrayVariable.getType()>0 && locationArrayVariable.getType()<3 && (barButton.getBackgroundTintList().getDefaultColor()==-524991+100 || restaurentButton.getBackgroundTintList().getDefaultColor()==-10879633+100)){


                        locationInfoTextView.setText(locationArrayVariable.getText());

                        sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);




                    }else if(locationArrayVariable.getType()>2 && locationArrayVariable.getType()<5 && (cafeButton.getBackgroundTintList().getDefaultColor()==-31949+100 || restaurentButton.getBackgroundTintList().getDefaultColor()==-10879633+100)){
                        //fragmentImageView.setImageBitmap();
                        locationInfoTextView.setText(locationArrayVariable.getText());

                        sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);




                    }else if(locationArrayVariable.getType()>4 && cafeButton.getBackgroundTintList().getDefaultColor()==-31949+100){

                        locationInfoTextView.setText(locationArrayVariable.getText());
                        sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);




                    }


                }
            }
            Log.e(TAG, "touch coordinates X" + touchX +" Y "+ touchY  );
            ImageView view = (ImageView) v;
            view.bringToFront();
            viewTransformation(view, event);
            return true;
        }
    });

XML для деятельности.

 <?xml version="1.0" encoding="utf-8"?>
  <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:design="http://schemas.android.com/apk/res-auto">



<ImageView
    android:id="@+id/limerickMapImageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:src="@drawable/limerickmap" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/centreButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="16dp"
    android:src="@drawable/centre"
    app:backgroundTint="@color/linkBlue" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/restaurentButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="270dp"
    android:layout_marginBottom="570dp"
    android:src="@drawable/restaurent"
    app:backgroundTint="@color/green1" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/barButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="340dp"
    android:layout_marginBottom="570dp"
    android:src="@drawable/bar"
    app:backgroundTint="@color/blue3" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/infoButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="138dp"
    android:layout_marginBottom="570dp"
    android:src="@drawable/info" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/cafeButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="205dp"
    android:layout_marginBottom="570dp"
    android:src="@drawable/cafe"
    app:backgroundTint="@color/orange1" />



<include
    layout="@layout/bottom_sheet"
     />

1 Ответ

0 голосов
/ 15 марта 2019

Простое решение я удалил view.bringToFront ();

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...