由于m有一个地图活动..除了浮动按钮之外没有其他按钮或文本字段正在点击..缩放地图zvoom或滚动无效工作。这是我的代码
content_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.ravi.poison.MainActivity"
tools:showIn="@layout/activity_main">
<fragment
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
tools:layout="@layout/select_dialog_item_material"
android:layout_alignParentTop="true"
android:layout_marginLeft="-20dp"
android:layout_marginTop="-20dp"
android:layout_marginRight="-20dp"
android:layout_marginBottom="-20dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:id="@+id/bitch">
<EditText
android:layout_width="281dp"
android:layout_height="match_parent"
android:id="@+id/searchloc"
android:layout_weight="1.03" />
<Button
android:layout_width="59dp"
android:layout_height="wrap_content"
android:id="@+id/search"
android:background="@android:drawable/ic_menu_view" />
<!--
android:background="@drawable/blue"
-->
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/bitch"
android:orientation="vertical"
android:id="@+id/linearLayout">
<TextView
android:layout_width="fill_parent"
android:layout_height="63dp"
android:id="@+id/cotxt"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cofnd"
android:text="Get lat lon"
android:layout_gravity="center"
android:layout_below="@+id/linearLayout"
android:layout_alignLeft="@+id/map"
android:layout_alignStart="@+id/map" />
</LinearLayout>
</RelativeLayout>
activity_main.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"
android:fitsSystemWindows="true"
tools:context="com.example.ravi.poison.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<include layout="@layout/nav_drawer"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_menu_mylocation" />
</android.support.design.widget.CoordinatorLayout>
nav_drawer.xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/fragmentholder"
>
</FrameLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/navlist"
android:background="#dedede"
android:layout_gravity="start">
</ListView>
</android.support.v4.widget.DrawerLayout>
MainActivity.java
package com.example.ravi.poison;
import android.*;
import android.Manifest;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.media.audiofx.BassBoost;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.*;
public class MainActivity extends AppCompatActivity {
TextView cotxt;
Button cobtn;
double lat = 0;
double lon = 0;
LocationManager locationManager;
LocationListener locationListener;
LatLng longi = new LatLng(23.345367, 172.1243254);
private GoogleMap map;
@TargetApi(Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cotxt = (TextView) findViewById(R.id.cotxt);
cobtn = (Button) findViewById(R.id.cofnd);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
map.clear();
//map.addMarker(new MarkerOptions().position(longi).title("Surry"));
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
cotxt.setText(location.getLongitude() + " " + location.getLatitude());
lon = location.getLongitude();
lat = location.getLatitude();
longi = new LatLng(lat, lon);
map.addMarker(new MarkerOptions().position(longi).title("Hey there! I am using whatsapp :v"));
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
Intent i = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(i);
}
};
configureButton();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
CameraUpdate cu = CameraUpdateFactory.newLatLngZoom(longi, 17);
map.animateCamera(cu);
Snackbar.make(view, "Go fun yourself", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
}
private void configureButton() {
cobtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ActivityCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
else{
locationManager.requestLocationUpdates("gps", 5000, 0, locationListener);
map.setMyLocationEnabled(true);
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
我该怎么办?