Почему не работает увеличение в Android Coordinator Layout? - PullRequest
1 голос
/ 30 июня 2019

Я надеюсь добавить постоянные нижние диалоговые окна к моему приложению карты Android и начал изменять мой файл layout.xml. Тем не менее, я обнаружил, что пинч для увеличения / уменьшения масштаба и управления масштабированием +/- не работают. Единственное, что работает, это круглая кнопка «Переместить в текущее местоположение» (та, которая обычно находится в верхнем правом углу экрана.

Мой оригинальный XML-файл выглядит следующим образом:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:id="@+id/tlll"
>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/llhelpgraphic"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".08"
    android:background="#000000"
    android:orientation="horizontal">

    <ImageButton
        android:id="@+id/helpButton"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_margin="3dp"
        android:adjustViewBounds="true"
        android:src="@drawable/help5"
        />

    <ImageView
        android:id="@+id/titleview"
        android:layout_height="match_parent"
        android:layout_width="fill_parent"
        android:layout_weight="1"
        android:src="@drawable/title"
        />

</LinearLayout>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frlayout"
    android:layout_weight=".82"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    >

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".FindIt" />

</FrameLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".10"
    android:background="#004D79"
    android:orientation="horizontal">

    <EditText
        android:id="@+id/addressText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="7dp"
        android:layout_weight="1"
        android:background="#FFFFFF"
        android:text="Enter UK address or postcode">
    </EditText>

    <Button
        android:id="@+id/findButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:text="Find">
    </Button>
</LinearLayout>

Мой измененный файл выглядит следующим образом:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bgLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:id="@+id/tlll"
>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/llhelpgraphic"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".08"
    android:background="#000000"
    android:orientation="horizontal">

    <ImageButton
        android:id="@+id/helpButton"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_margin="3dp"
        android:adjustViewBounds="true"
        android:src="@drawable/help5"
        />

    <ImageView
        android:id="@+id/titleview"
        android:layout_height="match_parent"
        android:layout_width="fill_parent"
        android:layout_weight="1"
        android:src="@drawable/title"
        />

</LinearLayout>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frlayout"
    android:layout_weight=".82"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    >

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".FindIt" />

</FrameLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".10"
    android:background="#004D79"
    android:orientation="horizontal">

    <EditText
        android:id="@+id/addressText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="7dp"
        android:layout_weight="1"
        android:background="#FFFFFF"
        android:text="Enter UK address or postcode">
    </EditText>

    <Button
        android:id="@+id/findButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:text="Find">
    </Button>
</LinearLayout>

</LinearLayout>
<android.support.v4.widget.NestedScrollView
    android:id="@+id/loclistdialog"
    android:layout_width="match_parent"
    android:layout_height="250dp"
    android:clipToPadding="true"
  app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text=""
            android:id="@+id/loclist"
            />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

Единственные изменения, которые я сделал, - это добавление CoordinatorLayout и NestedScrollView в файл. Может кто-нибудь помочь, пожалуйста?

...