FlipViewPager.Draco
1.0.0
此項目旨在提供一個可在 ListView 中使用的工作翻頁實作。產地:[Yalantis] (https://yalantis.com/?utm_source=github)
檢查這個[Dribbble 上的項目] (https://dribbble.com/shots/1758298-Find-Friends-Interaction?list=users&offset=35)
在 [Youtube] (https://www.youtube.com/watch?v=zNRPjS53m5w) 上查看其工作原理
#用法
對於有效的實現,請查看範例專案 - 範例
要獲得相同的網格視圖,您應該:
將庫包含為本機庫項目:
compile ' com.yalantis:flipviewpager:1.0.0 '
建立您的主佈局,它將是兩個項目合併在一起的視圖:
<!-- ... -->
< ImageView
android : id = " @+id/first "
xmlns : android = " http://schemas.android.com/apk/res/android "
android : layout_width = " 0dp "
android : layout_weight = " 1 "
android : contentDescription = " left image "
android : layout_height = " wrap_content "
android : scaleType = " fitXY " />
< LinearLayout
android : layout_width = " 1dp "
android : layout_weight = " 0 "
android : background = " #000000 "
android : layout_height = " fill_parent " />
< ImageView
android : id = " @+id/second "
android : layout_width = " 0dp "
android : layout_weight = " 1 "
android : contentDescription = " right image "
android : layout_height = " wrap_content "
android : scaleType = " fitXY " />
<!-- ... -->
建立佈局以顯示每個合併項目的附加資訊:
<!-- ... -->
< com .yalantis.flip.sample.views.FontTextView
style = " @style/TextView.Nickname "
android : id = " @+id/nickname " />
< LinearLayout
android : layout_below = " @+id/nickname "
android : id = " @+id/interestsPrimary "
style = " @style/LinearLayout.Interests " >
< com .yalantis.flip.sample.views.FontTextView
style = " @style/TextView.Interest "
android : id = " @+id/interest_1 " />
<!-- ... -->
</ LinearLayout >
建立適配器並從BaseFlipAdapter<T>
擴展它
class FriendsAdapter extends BaseFlipAdapter < Friend > {
@ Override
public View getPage ( int position ,
View convertView ,
ViewGroup parent ,
Friend friend1 ,
Friend friend2 ) {
// ...
}
class FriendsHolder {
// ...
}
}
在ListView
中設定適配器
final ListView friends = ( ListView ) findViewById ( R . id . friends );
friends . setAdapter ( new FriendsAdapter ( this , Utils . friends , settings ));
您可以像在常規ListView
中一樣處理點擊
friends . setOnItemClickListener ( new AdapterView . OnItemClickListener () {
@ Override
public void onItemClick ( AdapterView <?> parent , View view , int position , long id ) {
Friend friend = ( Friend ) friends . getAdapter (). getItem ( position );
Toast . makeText ( FriendsActivity . this , friend . getNickname (), Toast . LENGTH_SHORT ). show ();
}
});
更多選項將很快添加:)
#定制
要自訂頁面將首先顯示 - 建立 FlipSettings 物件並將其傳遞到適配器中
FlipSettings settings = new FlipSettings . Builder (). defaultPage ( 1 ). build ();
#相容性
如果您向我們發送使用我們組件的項目的鏈接,我們將非常高興。只需發送電子郵件至 [email protected] 如果您對動畫有任何疑問或建議,請告訴我們。
PS 我們將發布更多包含在程式碼中的精彩內容以及關於如何讓 Android (iOS) 的 UI 變得更好的教學。敬請關注!
Copyright 2017, Yalantis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.