android 折叠式布局,folding-cell-android 翻转效果可折叠式布局

Just download the package from here and add it to your project classpath, or just use the maven repo:

Gradle:

'com.ramotion.foldingcell:folding-cell:1.2.2'

SBT:

libraryDependencies += "com.ramotion.foldingcell" % "folding-cell" % "1.2.2"

Maven:

com.ramotion.foldingcellgroupId>

folding-cellartifactId>

1.2.2version>

dependency>

Basic usage

Add com.ramotion.foldingcell.FoldingCell to your layout ​

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/folding_cell"

android:layout_width="match_parent"

android:layout_height="wrap_content">

com.ramotion.foldingcell.FoldingCell>

​ 2. Add exactly two child elements to your cell. The first child (content view) always represents the unfolded state layout and the second child (title view) represents folded state layout. Of course, those layouts can contain any number of child elements and they can be any complexity, but to work correctly, there are some limitations: content view height must be at least 2x times greater than title view height, and the height of each of those layouts must be set to android:layout_height="wrap_content". If you want to set exact height in dp , you can set height for child elements in your own layout inside content view or title view. Also, you need to hide your content view layout using android:visibility="gone". ​

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/folding_cell"

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:id="@+id/cell_content_view"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@android:color/holo_green_dark"

android:visibility="gone">

android:layout_width="match_parent"

android:layout_height="250dp" />

FrameLayout>

android:id="@+id/cell_title_view"

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:layout_width="match_parent"

android:layout_height="100dp"

android:background="@android:color/holo_blue_dark" />

FrameLayout>

com.ramotion.foldingcell.FoldingCell>

​ 3. Almost done! Two steps remain! For correct animation, you need to set up two properties on the root element(s) of your Folding Cell: ​

android:clipChildren="false"

android:clipToPadding="false"

​ 4. Final step! Add onClickListener to your Folding Cell in MainActivity.java to toggle animation: ​

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// get our folding cell

final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);

// attach click listener to folding cell

fc.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

fc.toggle(false);

}

});

}

​ 5. Extra step - customizing cell settings. For now, there are three main parameters - animation time, back side color and additional flips count. If first two do not cause questions, the third requires an some explanation. It is count of flips to be executed after first(main) flip. Default value is 0(auto choose). Also there is a fourth, additional parameter - camera height, it controls level(depth) of 3d effect. There are two ways to change cell settings: From xml layout file with res-auto namespace xmlns:folding-cell="http://schemas.android.com/apk/res-auto":

folding-cell:animationDuration="1000"

folding-cell:backSideColor="@color/bgBackSideColor"

folding-cell:additionalFlipsCount="2"

folding-cell:cameraHeight="30"

Or from code:

// get our folding cell

final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);

// set custom parameters

fc.initialize(1000, Color.DKGRAY, 2);

// or with camera height parameter

fc.initialize(30, 1000, Color.DKGRAY, 2);

​ You can find this and other, more complex, examples in this repository ​

https://github.com/Ramotion/folding-cell-android

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值