-
-
Save Lingviston/1d97660f7a5888ca0f76 to your computer and use it in GitHub Desktop.
public class MainActivity extends AppCompatActivity implements SlidingUpPanelLayout.PanelSlideListener{ | |
private SupportMapFragment mMapFragment; | |
private SlidingUpPanelLayout mSlidingUpPanelLayout; | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
mSlidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.slidingUpLayout); | |
mSlidingUpPanelLayout.setPanelSlideListener(this); | |
mMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); | |
mMapFragment.getMapAsync(new OnMapReadyCallback() { | |
@Override | |
public void onMapReady(GoogleMap googleMap) { | |
LatLng latLng = new LatLng(53.9, 27.5666667); | |
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 17); | |
MarkerOptions options = new MarkerOptions().position(latLng); | |
googleMap.addMarker(options); | |
googleMap.moveCamera(cameraUpdate); | |
} | |
}); | |
} | |
@Override | |
public void onPanelSlide(View panel, final float slideOffset) { | |
final int panelHeight = findViewById(R.id.panel).getHeight(); | |
final int visiblePanelHeight = mSlidingUpPanelLayout.getPanelHeight(); | |
mMapFragment.getMapAsync(new OnMapReadyCallback() { | |
@Override | |
public void onMapReady(GoogleMap googleMap) { | |
CameraPosition cameraPosition = googleMap.getCameraPosition(); | |
CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition); | |
googleMap.setPadding(0,0,0, (int) (visiblePanelHeight + (panelHeight - visiblePanelHeight) * slideOffset)); | |
googleMap.moveCamera(cameraUpdate); | |
} | |
}); | |
} | |
@Override | |
public void onPanelCollapsed(View panel) { | |
} | |
@Override | |
public void onPanelExpanded(View panel) { | |
} | |
@Override | |
public void onPanelAnchored(View panel) { | |
} | |
@Override | |
public void onPanelHidden(View panel) { | |
} | |
} |
<?xml version="1.0" encoding="utf-8"?> | |
<com.sothree.slidinguppanel.SlidingUpPanelLayout | |
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:id="@+id/slidingUpLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:gravity="bottom" | |
app:umanoOverlay="true" | |
app:umanoPanelHeight="40dp" | |
app:umanoShadowHeight="0dp" | |
app:umanoFadeColor="@android:color/transparent"> | |
<fragment | |
android:id="@+id/map" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:name="com.google.android.gms.maps.SupportMapFragment" | |
tools:context=".MapsActivity"/> | |
<TextView | |
android:id="@+id/panel" | |
android:layout_width="match_parent" | |
android:layout_height="400dp" | |
android:text="Drag me" | |
android:background="@android:color/white" | |
android:gravity="center_horizontal|top"/> | |
</com.sothree.slidinguppanel.SlidingUpPanelLayout> |
Yes. By default tapping on dragview again sets state to COLLAPSED and it's ok in your case. You incorrectly understand the meaning of app:umanoPanelHeight attribute. It's height of the visible part in collapsed state. So you have to set it to 0dp and probably set TableLayout's height to 300 dp.
Or probably you can simply set state to HIDDEN on second tap but my opinion is that the first solution is more correct.
I understood the meaning . But its really like troubling me with one another issue . Setting an panelHeight = 0 will raise a problem : on clicking marker no panel will show up . 2 . On making table layout to 300 dp : It will show panel on launch of app instead clicking marker and come up .
:( So thats the issue . Should i change in slidingUpPanel file instead changing to this ?
Actually slidingUpPanel is collapsed on start. You defenitly do something wrong.
I have done exactly what u said . I mean just changes in xml 's . Ahha.... mine is Hidden on start might be thats why . As i want it changed to collapsed on marker click only
And while using answer i learnt many things . Really . this not only resolved my issue but help exploring and learning stuff .