当前位置:首页 > 安卓源码 > 功能分类 > 其他 >

Android开发实现漂亮的的交互效果源码

时间:2017-10-13 17:18 来源:互联网 作者:源码搜藏收藏

  • 源码类别:其他
  • 源码大小:未知
  • 编码格式:gbk,utf8,不限
  • 运行环境:Android studio
  • 广告推荐

一个竖直方向的SlidingPanelLayout,支持加载多个面板,可以灵活地实现漂亮的的交互效果

摇篮

根项目:build.gradle

所有项目{

 repositories {
    ...
    maven { url "https://jitpack.io" }
 }


app:build.gradle

依赖{

 compile 'com.github.woxingxiao:SlidingUpPanelLayout:1.1.0'


用法

  1. java(动态方式)

SlidingUpPanelLayout.setAdapter(new SlidingUpPanelLayout.Adapter(){

  private final int mSize = mWeatherList.size();

  @Override
  public int getItemCount() {
      return mSize;
  }

  @NonNull
  @Override
  public ISlidingUpPanel onCreateSlidingPanel(int position) {
      WeatherPanelView panel = new WeatherPanelView(DemoActivity1.this);
      if (position == 0) {
          panel.setSlideState(EXPANDED);
      } else {
          panel.setSlideState(HIDDEN);
      }

      return panel;
  }

  @Override
  public void onBindView(final ISlidingUpPanel panel, int position) {
      if (mSize == 0)
          return;

      BaseWeatherPanelView BasePanel = (BaseWeatherPanelView) panel;
      BasePanel.setWeatherModel(mWeatherList.get(position));
      BasePanel.setClickable(true);
      BasePanel.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              if (panel.getSlideState() != EXPANDED) {
                  mSlidingUpPanelLayout.expandPanel();
              } else {
                  mSlidingUpPanelLayout.collapsePanel();
              }
          }
      });
  }

}); 
转到样品了解更多详情。

  1. xml(静态方式)

<?xml version =“1.0”encoding =“utf-8”?> 
<com.xw.repo.supl.SlidingUpPanelLayout

android:id="@+id/sliding_up_panel_layout"
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">

<!-- background view, the position at 0 can only have one directly view, it can be a view or a layout. -->
<android.support.constraint.ConstraintLayout
    android:id="@+id/bg_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#616161">

    <TextView
        android:id="@+id/pick_hint_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="120dp"
        android:text="Pick a credit card to pay"
        android:textColor="@android:color/white"
        android:textSize="20sp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <TextView
        android:id="@+id/pay_hint_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="260dp"
        android:alpha="0.0"
        android:drawablePadding="8dp"
        android:drawableTop="@mipmap/ic_finger_print"
        android:text="Pay with Touch ID"
        android:textColor="@android:color/white"
        android:textSize="18sp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:alpha="1.0"/>
</android.support.constraint.ConstraintLayout>

<!-- panel view, the position from 1 to n must be the one which implemented the interface ISlidingUpPanel.-->
<com.xw.sample.slidinguppanellayout.demo2.CardPanelView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:cpv_cardCount="4"
    app:cpv_cardImageRes="@mipmap/pic_card1"
    app:cpv_cardPosition="0"/>

<com.xw.sample.slidinguppanellayout.demo2.CardPanelView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:cpv_cardCount="4"
    app:cpv_cardImageRes="@mipmap/pic_card2"
    app:cpv_cardPosition="1"/>

<com.xw.sample.slidinguppanellayout.demo2.CardPanelView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:cpv_cardCount="4"
    app:cpv_cardImageRes="@mipmap/pic_card3"
    app:cpv_cardPosition="2"/>

<com.xw.sample.slidinguppanellayout.demo2.CardPanelView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:cpv_cardCount="4"
    app:cpv_cardImageRes="@mipmap/pic_card4"
    app:cpv_cardPosition="3"/>

</com.xw.repo.supl.SlidingUpPanelLayout>

本站资源仅限于学习研究,严禁从事商业或者非法活动! 源码搜藏网所有源码来自互联网转载与用户上传分享,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!

其他下载排行

最新文章