SlidingUpPanelLayout simple to use

SlidingUpPanelLayout simple to use

SlidingUpPanelLayout is an open source library on github https://github.com/umano/AndroidSlidingUpPanel , the main effect is to slide up or click to expand the panel with animation:

First, add dependency package

implementation 'com.sothree.slidinguppanel:library:3.4.0'

Step 2: add page layout

<?xml version="1.0" encoding="utf-8"?>
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#DDDDDD"
    android:gravity="bottom"
    sothree:umanoClipPanel="true"
    sothree:umanoOverlay="true"
    sothree:umanoPanelHeight="145dp"
    sothree:umanoShadowHeight="0dp">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Main Content!"
        android:textSize="16sp" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.8">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="105dp"
                    android:layout_marginTop="35dp"
                    android:background="#F8F8F8"
                    android:orientation="horizontal">

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_marginTop="35dp"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:descendantFocusability="beforeDescendants"
                        android:gravity="center"
                        android:orientation="vertical">

                        <TextView
                            android:id="@+id/entity_map_bottom_ratingTv"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Trip score"
                            android:textSize="18sp" />

                        <RatingBar
                            android:id="@+id/entity_map_bottom_ratingBar"
                            style="?android:attr/ratingBarStyleSmall"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="8dp" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="40dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:orientation="vertical">

                        <TextView
                            android:id="@+id/entity_driver_bottom_driverNameTv"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Zhang    Four"
                            android:textSize="18sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="35dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Trip cost"
                            android:textSize="18sp" />

                        <TextView
                            android:id="@+id/entity_driver_bottom_feeTv"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="8dp"
                            android:text="¥ 50.00"
                            android:textSize="18sp" />
                    </LinearLayout>
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:background="#FFFFFF"></LinearLayout>
            </LinearLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/transparent">

                <ImageView
                    android:id="@+id/entity_map_bottom_charImg"
                    android:layout_width="70dp"
                    android:layout_height="70dp"
                    android:layout_centerInParent="true"
                    android:src="@mipmap/ic_launcher" />
            </RelativeLayout>

        </RelativeLayout>

    </RelativeLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>

summary

  1. SlidingUpPanelLayout needs to be placed in the outermost package.
  2. We need to add < item name = "Android: windowactionbaroverlay" > true < / item > to styles on the Internet. We haven't seen the impact after testing whether to add it or not
  3. There is a probability of jamming, which has not been solved yet.
  4. sothree:umanoOverlay is a very important property. It is used to control whether the background is covered by the cover mask. It can be set to false to see

Tags: Android github xml encoding

Posted on Sat, 02 May 2020 23:50:02 -0700 by cgraz