2
我有兩個問題。我的想法是:BottomSheet - 爲什麼在視圖上按FAB按鈕?當我再次關注地圖時如何隱藏BottoSheet?
當我點擊一個googlemap的標記時,底部表格顯示了標記的詳細信息。
我現在有兩個問題。
- 當上標記某次點擊,bottomsheet視圖向上滑動和Te屏蓋一半(我想)覆蓋地圖,並在2個FAB按鈕保持仍然在bottomsheet(我想bottomSheet他們下面) 。
- 當bottomSheet顯示時,我希望如果我點擊地圖,bottomSheet應該消失(它不)。
這是我的代碼:
main_layout_activity.xml:
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
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>
<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="ankic.it.nasone.NasoneActivity" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_gravity="bottom|end|right"
app:backgroundTint="@color/white"
android:layout_margin="@dimen/fab_margin"
app:fabSize="normal"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_marginBottom="85dp"
android:layout_marginEnd="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
app:layout_anchor="@id/floatingButton"
app:layout_anchorGravity="top"
app:backgroundTint="@color/white"
/>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="350dp"
android:clipToPadding="true"
android:background="@android:color/holo_orange_light"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is a test dialog fragment"
android:textColor="@android:color/white"
android:textSize="16sp"
android:padding="16dp"
android:background="@android:color/holo_purple"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/immagine_lista"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
MyActivity.java
個這裏的片段:
public class MyActivity extends AppCompatActivity
{
protected FloatingActionButton floatingButton;
private FloatingActionButton fabAdd;
private BottomSheetBehavior mBottomSheetBehavior;
............
@Override
protected void onCreate(Bundle savedInstanceState) {
........
this.floatingButton = (FloatingActionButton) findViewById(R.id.floatingButton);
this.fabAdd=(FloatingActionButton)findViewById(R.id.fabAdd);
this.cl=(CoordinatorLayout)findViewById(R.id.coordinatorLayoutNasoni) ;
View bottomSheet = findViewById(R.id.bottom_sheet);
mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
return false;
}
});
}
}
我應該怎麼辦?