【发布时间】:2019-12-04 18:15:08
【问题描述】:
我想在我的项目中添加一个上滑面板。但我不知道该怎么做。我想在以下布局中添加滑动面板:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/mainFragment"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F7FEFF"
tools:context="app.meetgreet.meetgreet.MainActivity">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="app.meetgreet.meetgreet.MapsActivity" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="@color/colorAccent"
android:textSize="30sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/scrollView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/scrollView2"
app:layout_constraintVertical_bias="0.36" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:id="@+id/linearLayoutMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical" />
</ScrollView>
<ImageButton
android:id="@+id/imageButton"
style="@style/Widget.AppCompat.ImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@android:color/transparent"
android:contentDescription="@string/settings"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_icons8_benutzereinstellungen_64" />
</androidx.constraintlayout.widget.ConstraintLayout>
我已经实现了这个库:
implementation 'com.sothree.slidinguppanel:library:3.4.0'
以下部分应该是mainLayout。所以它不是滑动面板的一部分。它提供了一个谷歌地图。
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="app.meetgreet.meetgreet.MapsActivity" />
除 ImageButton 之外的所有其他视图都应该是滑动面板的一部分。 ImageButton 应该在屏幕的顶部,如果面板到达顶部,它就会消失。我希望有人可以帮助我实现它! 我已经尝试按照 GitHub 上的说明进行操作: https://github.com/umano/AndroidSlidingUpPanel 无论如何,它不起作用。
谢谢!
【问题讨论】:
标签: java android xml layout slidingpanelayout