android 廣告欄效果,實現android廣告欄效果

public classBannerLayout extendsRelativeLayout {

privateViewPager mViewPager; // 輪播容器// 指示器(圓點)容器privateLinearLayout indicatorContainer;

privateDrawable unSelectedDrawable;

privateDrawable selectedDrawable;

private intWHAT_AUTO_PLAY= 1000;

private booleanisAutoPlay= true; // 自動輪播private intitemCount;

private intselectedIndicatorColor= 0xffff0000;

private intunSelectedIndicatorColor= 0x88888888;

private inttitleBGColor= 0X33000000;

private inttitleColor= 0Xffffffff;

privateShape indicatorShape= Shape.oval;

private intselectedIndicatorHeight= 20;

private intselectedIndecatorWidth= 20;

private intunSelectedIndicatorHeight= 20;

private intunSelectedIndecatorWidth= 20;

private intautoPlayDuration= 4000;

private intscrollDuration= 900;

// 指示器中點和點之間的距離private intindicatorSpace= 15;

// 指示器整體的設置private intindicatorMargin= 20;

private static final inttitlePadding= 20;

private intdefaultImage;

private enumShape {

// 矩形 或 圓形的指示器rect, oval}

privateOnBannerItemClickListener mOnBannerItemClickListener;

privateHandler mHandler= newHandler(newHandler.Callback() {

@Overridepublic booleanhandleMessage(Message msg) {

if(msg.what== WHAT_AUTO_PLAY) {

if(mViewPager!= null) {

mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true);

mHandler.sendEmptyMessageDelayed(WHAT_AUTO_PLAY, autoPlayDuration);

}

}

return false;

}

});

publicBannerLayout(Context context) {

super(context);

init(null, 0);

}

publicBannerLayout(Context context, AttributeSet attrs) {

super(context, attrs);

init(attrs, 0);

}

publicBannerLayout(Context context, AttributeSet attrs, intdefStyleAttr) {

super(context, attrs, defStyleAttr);

init(attrs, defStyleAttr);

}

private voidinit(AttributeSet attrs, intdefStyleAttr) {

TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.BannerLayoutStyle, defStyleAttr, 0);

selectedIndicatorColor= array.getColor(R.styleable.BannerLayoutStyle_selectedIndicatorColor, selectedIndicatorColor);

unSelectedIndicatorColor= array.getColor(R.styleable.BannerLayoutStyle_unSelectedIndicatorColor, unSelectedIndicatorColor);

titleBGColor= array.getColor(R.styleable.BannerLayoutStyle_titleBGColor, titleBGColor);

titleColor= array.getColor(R.styleable.BannerLayoutStyle_titleColor, titleColor);

intshape = array.getInt(R.styleable.BannerLayoutStyle_indicatorShape, Shape.oval.ordinal());

for(Shape shape1 : Shape.values()) {

if(shape1.ordinal() == shape) {

indicatorShape= shape1;

break;

}

}

selectedIndecatorWidth= (int) array.getDimension(R.styleable.BannerLayoutStyle_selectedIndicatorWidth, selectedIndecatorWidth);

selectedIndicatorHeight= (int) array.getDimension(R.styleable.BannerLayoutStyle_selectedIndicatorHeight, selectedIndicatorHeight);

unSelectedIndecatorWidth= (int) array.getDimension(R.styleable.BannerLayoutStyle_unSelectedIndicatorWidth, unSelectedIndecatorWidth);

unSelectedIndicatorHeight= (int) array.getDimension(R.styleable.BannerLayoutStyle_unSelectedIndicatorHeight, unSelectedIndicatorHeight);

indicatorSpace= (int) array.getDimension(R.styleable.BannerLayoutStyle_indicatorSpace, indicatorSpace);

indicatorMargin= (int) array.getDimension(R.styleable.BannerLayoutStyle_indicatorMargin, indicatorMargin);

autoPlayDuration= array.getInt(R.styleable.BannerLayoutStyle_autoPlayDuration, autoPlayDuration);

scrollDuration= array.getInt(R.styleable.BannerLayoutStyle_scrollDuration, scrollDuration);

isAutoPlay= array.getBoolean(R.styleable.BannerLayoutStyle_isAutoPlay, isAutoPlay);

defaultImage= array.getResourceId(R.styleable.BannerLayoutStyle_defaultImage, defaultImage);

array.recycle();

LayerDrawable unSelectedLayerDrawable;

LayerDrawable selectedLayerDrawable;

GradientDrawable unSelectedGradientDrawable = newGradientDrawable();

GradientDrawable selectedGradientDtawbale = newGradientDrawable();

switch(indicatorShape) {

caserect:

unSelectedGradientDrawable.setShape(GradientDrawable.RECTANGLE);

selectedGradientDtawbale.setShape(GradientDrawable.RECTANGLE);

break;

caseoval:

unSelectedGradientDrawable.setShape(GradientDrawable.OVAL);

selectedGradientDtawbale.setShape(GradientDrawable.OVAL);

break;

}

unSelectedGradientDrawable.setColor(unSelectedIndicatorColor);

unSelectedGradientDrawable.setSize(unSelectedIndecatorWidth, unSelectedIndicatorHeight);

unSelectedLayerDrawable = newLayerDrawable(newDrawable[]{unSelectedGradientDrawable});

unSelectedDrawable= unSelectedLayerDrawable;

selectedGradientDtawbale.setColor(selectedIndicatorColor);

selectedGradientDtawbale.setSize(selectedIndecatorWidth, selectedIndicatorHeight);

selectedLayerDrawable = newLayerDrawable(newDrawable[]{selectedGradientDtawbale});

selectedDrawable= selectedLayerDrawable;

}

/*** 添加本地圖片**@paramviewRes圖片id集合*@paramtitles標題集合,可空*/public voidsetViewRes(List viewRes, List titles) {

List views = newArrayList<>();

itemCount= viewRes.size();

if(titles != null&& titles.size() != viewRes.size()) {

throw newIllegalStateException("views.size() != titles.size()");

}

// 把數量拼湊到三個以上if(itemCount< 1) {

throw newIllegalStateException("item count not equal zero");

} else if(itemCount< 2) {

views.add(getFrameLayoutView(viewRes.get(0), titles != null? titles.get(0) : null, 0));

views.add(getFrameLayoutView(viewRes.get(0), titles != null? titles.get(0) : null, 0));

views.add(getFrameLayoutView(viewRes.get(0), titles != null? titles.get(0) : null, 0));

} else if(itemCount< 3) {

views.add(getFrameLayoutView(viewRes.get(0), titles != null? titles.get(0) : null, 0));

views.add(getFrameLayoutView(viewRes.get(1), titles != null? titles.get(1) : null, 1));

views.add(getFrameLayoutView(viewRes.get(0), titles != null? titles.get(0) : null, 0));

views.add(getFrameLayoutView(viewRes.get(1), titles != null? titles.get(1) : null, 1));

} else{

for(inti = 0; i < viewRes.size(); i++) {

views.add(getFrameLayoutView(viewRes.get(i), titles != null? titles.get(i) : null, i));

}

}

setViews(views);

}

//添加網絡圖片路徑public voidsetViewUrls(Context context,List urls, List titles) {

List views = newArrayList<>();

itemCount= urls.size();

Log.e("TAG",titles.size()+"---90---"+urls.size());

if(titles != null&& titles.size() != itemCount) {

throw newIllegalStateException("views.size() != titles.size()");

}

//主要是解決當item為小于3個的時候滑動有問題,這里將其拼湊成3個以上if(itemCount< 1) {//當item個數0throw newIllegalStateException("item count not equal zero");

} else if(itemCount< 2) { //當item個數為1views.add(getFrameLayoutView(context,urls.get(0), titles != null? titles.get(0) : null, 0));

views.add(getFrameLayoutView(context,urls.get(0), titles != null? titles.get(0) : null, 0));

views.add(getFrameLayoutView(context,urls.get(0), titles != null? titles.get(0) : null, 0));

} else if(itemCount< 3) {//當item個數為2views.add(getFrameLayoutView(context,urls.get(0), titles != null? titles.get(0) : null, 0));

views.add(getFrameLayoutView(context,urls.get(1), titles != null? titles.get(1) : null, 1));

views.add(getFrameLayoutView(context,urls.get(0), titles != null? titles.get(0) : null, 0));

views.add(getFrameLayoutView(context,urls.get(1), titles != null? titles.get(1) : null, 1));

} else{

for(inti = 0; i < urls.size(); i++) {

views.add(getFrameLayoutView(context,urls.get(i), titles != null? titles.get(i) : null, i));

}

}

setViews(views);

}

private voidsetViews(finalList views) {

mViewPager= newViewPager(getContext());

addView(mViewPager);

setSliderTransformDuration(scrollDuration);

//初始化indicatorContainerindicatorContainer= newLinearLayout(getContext());

indicatorContainer.setGravity(Gravity.CENTER_VERTICAL);

LayoutParams params = newLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

// 設置 指示點的位置 ALIGN_PARENT_RIGHT表示居右 CENTER_HORIZONTAL表示居中params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

//設置marginparams.setMargins(indicatorMargin, indicatorMargin, indicatorMargin, indicatorMargin);

//添加指示器容器布局到SliderLayoutaddView(indicatorContainer, params);

//初始化指示器,并添加到指示器容器布局for(inti = 0; i < itemCount; i++) {

ImageView indicator = newImageView(getContext());

indicator.setLayoutParams(newViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

indicator.setPadding(indicatorSpace, indicatorSpace, indicatorSpace, indicatorSpace);

indicator.setImageDrawable(unSelectedDrawable);

indicatorContainer.addView(indicator);

}

LoopPagerAdapter pagerAdapter = newLoopPagerAdapter(views);

mViewPager.setAdapter(pagerAdapter);

//設置當前item到Integer.MAX_VALUE中間的一個值,看起來像無論是往前滑還是往后滑都是ok的//如果不設置,用戶往左邊滑動的時候已經劃不動了inttargetItemPosition = Integer.MAX_VALUE/ 2- Integer.MAX_VALUE/ 2% itemCount;

mViewPager.setCurrentItem(targetItemPosition);

switchIndicator(targetItemPosition % itemCount);

mViewPager.addOnPageChangeListener(newViewPager.SimpleOnPageChangeListener() {

@Overridepublic voidonPageSelected(intposition) {

switchIndicator(position % itemCount);

}

});

startAutoPlay();

}

/*** 開始自動輪播*/public voidstartAutoPlay() {

stopAutoPlay(); // 避免重復消息if(isAutoPlay) {

mHandler.sendEmptyMessageDelayed(WHAT_AUTO_PLAY, autoPlayDuration);

}

}

@Overrideprotected voidonWindowVisibilityChanged(intvisibility) {

super.onWindowVisibilityChanged(visibility);

if(visibility == VISIBLE) {

startAutoPlay();

} else{

stopAutoPlay();

}

}

/*** 停止自動輪播*/public voidstopAutoPlay() {

if(isAutoPlay) {

mHandler.removeMessages(WHAT_AUTO_PLAY);

}

}

private voidsetSliderTransformDuration(intscrollDuration) {

try{

Field mScroller = ViewPager.class.getDeclaredField("mScroller");

mScroller.setAccessible(true);

FixedSpeedScroller fixedSpeedScroller = newFixedSpeedScroller(mViewPager.getContext(), null, scrollDuration);

mScroller.set(mViewPager, fixedSpeedScroller);

} catch(Exception e) {

e.printStackTrace();

}

}

@Overridepublic booleandispatchTouchEvent(MotionEvent ev) {

switch(ev.getAction()) {

caseMotionEvent.ACTION_DOWN:

stopAutoPlay();

break;

caseMotionEvent.ACTION_CANCEL:

caseMotionEvent.ACTION_UP:

startAutoPlay();

break;

}

return super.dispatchTouchEvent(ev);

}

/*** 切換指示器狀態**@paramcurrentPosition當前位置*/private voidswitchIndicator(intcurrentPosition) {

for(inti = 0; i < indicatorContainer.getChildCount(); i++) {

((ImageView) indicatorContainer.getChildAt(i)).setImageDrawable(i == currentPosition ? selectedDrawable: unSelectedDrawable);

}

}

public voidsetOnBannerItemClickListener(OnBannerItemClickListener onBannerItemClickListener) {

this.mOnBannerItemClickListener= onBannerItemClickListener;

}

@NonNullprivateFrameLayout getFrameLayoutView(Context context, String url, String title, final intposition) {

FrameLayout frameLayout = newFrameLayout(getContext());

FrameLayout.LayoutParams layoutParams = newFrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

layoutParams.gravity= Gravity.CENTER;

ImageView imageView = newImageView(getContext());

frameLayout.addView(imageView);

frameLayout.setOnClickListener(newOnClickListener() {

@Overridepublic voidonClick(View v) {

if(mOnBannerItemClickListener!= null) {

mOnBannerItemClickListener.onItemClick(position);

}

}

});

imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

if(defaultImage!= 0){

Glide.with(getContext()).load(url).placeholder(defaultImage).centerCrop().into(imageView);

}else{

Glide.with(getContext()).load(url).centerCrop().into(imageView);

}

if(!TextUtils.isEmpty(title)) {

TextView textView = newTextView(getContext());

textView.setText(title);

textView.setTextColor(titleColor);

textView.setPadding(titlePadding, titlePadding, titlePadding, titlePadding);

textView.setBackgroundColor(titleBGColor);

textView.getPaint().setFakeBoldText(true);

layoutParams.gravity= Gravity.BOTTOM;

frameLayout.addView(textView, layoutParams);

}

returnframeLayout;

}

@NonNullprivateFrameLayout getFrameLayoutView(Integer res, String title, final intposition) {

FrameLayout frameLayout = newFrameLayout(getContext());

FrameLayout.LayoutParams layoutParams = newFrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

layoutParams.gravity= Gravity.CENTER;

ImageView imageView = newImageView(getContext());

frameLayout.addView(imageView);

frameLayout.setOnClickListener(newOnClickListener() {

@Overridepublic voidonClick(View v) {

if(mOnBannerItemClickListener!= null) {

mOnBannerItemClickListener.onItemClick(position);

}

}

});

imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

Glide.with(getContext()).load(res).centerCrop().into(imageView);

if(!TextUtils.isEmpty(title)) {

TextView textView = newTextView(getContext());

textView.setText(title);

textView.setTextColor(titleColor);

textView.setPadding(titlePadding, titlePadding, titlePadding, titlePadding);

textView.setBackgroundColor(titleBGColor);

textView.getPaint().setFakeBoldText(true);

layoutParams.gravity= Gravity.BOTTOM;

frameLayout.addView(textView, layoutParams);

}

returnframeLayout;

}

public interfaceOnBannerItemClickListener {

voidonItemClick(intposition);

}

public classLoopPagerAdapter extendsPagerAdapter {

privateList views;

publicLoopPagerAdapter(List views) {

this.views= views;

}

@Overridepublic intgetCount() {

//Integer.MAX_VALUE = 2147483647returnInteger.MAX_VALUE;

}

@Overridepublic booleanisViewFromObject(View view, Object object) {

returnview == object;

}

@OverridepublicObject instantiateItem(ViewGroup container, intposition) {

if(views.size() > 0) {

//position % view.size()是指虛擬的position會在[0,view.size())之間循環View view = views.get(position % views.size());

if(container.equals(view.getParent())) {

container.removeView(view);

}

container.addView(view);

returnview;

}

return null;

}

@Overridepublic voiddestroyItem(ViewGroup container, intposition, Object object) {

}

}

public classFixedSpeedScroller extendsScroller {

private intmDuration= 1000;

publicFixedSpeedScroller(Context context) {

super(context);

}

publicFixedSpeedScroller(Context context, Interpolator interpolator) {

super(context, (android.view.animation.Interpolator) interpolator);

}

publicFixedSpeedScroller(Context context, Interpolator interpolator, intduration) {

this(context, interpolator);

mDuration= duration;

}

@Overridepublic voidstartScroll(intstartX, intstartY, intdx, intdy, intduration) {

// Ignore received duration, use fixed one insteadsuper.startScroll(startX, startY, dx, dy, mDuration);

}

@Overridepublic voidstartScroll(intstartX, intstartY, intdx, intdy) {

// Ignore received duration, use fixed one insteadsuper.startScroll(startX, startY, dx, dy, mDuration);

}

}

}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/536563.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/536563.shtml
英文地址,請注明出處:http://en.pswp.cn/news/536563.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

自我練習

<!doctype html><html><head><meta charset"utf-8"><title>無標題文檔</title><link rel"icon" href"../HTMLWork/day03/psb.ico.ico" type"img/*"></head><body> <a na…

android studio按鈕槽函數,AndroidStudio按鈕Button退出程序

AndroidStudio 3.1.41.創建一個新的項目&#xff0c;項目名稱為Button&#xff0c;界面為activity_button.xml2.打開activity_button.xml3.點擊HelloWorld標簽&#xff0c;按Delete刪除4.左側組件欄選擇Common - Button5.將Button組件拖到界面上&#xff0c;大概中間的位置6.右…

cobbler介紹與部署

cobbler介紹 Cobbler是一個Linux系統安裝的服務&#xff0c;可以通過網絡啟動(PXE)的方式來快速安裝、重裝物理服務器和虛擬機&#xff0c;同時還可以管理DHCP&#xff0c;DNS等。 Cobbler可以使用命令行方式管理&#xff0c;也提供了基于Web的界面管理工具(cobbler-web)&#…

android wifi視頻監控軟件,WiFi環境下Android智能視頻監控系統研究與實現

摘要&#xff1a;在互聯網飛速發展和移動互聯網強勢崛起的時代,科技產品服務于普通生活是新興行業必然的發展趨勢;監控系統是物聯網時代各個領域必然爭取的可控制系統。隨著無線技術和移動終端設備的高歌猛進,移動終端智能無線視頻監控系統成為時下監控領域發展的熱點方向。無線…

android 本地地址轉換為url,android本地mipmap圖片轉url、絕對路徑轉URL URL URI File Path 轉換...

標簽&#xff1a; url uri file pathFile to URI:File file ...;URI uri file.toURI();File to URL:File file ...;URL url file.toURI().URL();URL to File:URL url ...;File file new Path(url.getPath()).toFile();URI to URL:URI uri ...;URL url uri.toURL();URL …

ORACLE數據庫導出導入數據

準備工作&#xff1a; 1、登錄管理員system 2、create directory dbdata as C:\oracle\tempData;--創建備份文件夾 3、grant read,write on directory dbdata to gsjk2018;--授權讀寫為用戶 --導出(每次修改文件名)expdp gsjk2018/gsjk2018_vimtech10.0.73.32:1521/orcl direct…

linux sed名寧,Linux shell利用sed批量更改文件名的方法

微子網絡與大家分享了在Linux shell中使用sed批量更改文件名的方法。希望你看完這篇文章有所收獲。大家一起討論一下。示例去除特定字符目標&#xff1a;把2017-01-01.jpg和2018-01-01.jpg變成20170101.jpg和20180101.jpg方法&#xff1a;用空值替換全部for filein ls | grep …

android手機給iphone越獄,一臺ROOT后的安卓手機:可以用來給iOS 13越獄了

iOS 13時代的越獄工具主要包括unc0ver和Checkra1n兩款&#xff0c;前者最新的v4.2.1版本已經支持A9到A13設備從除了支持的設備和系統多&#xff0c;unc0ver的一大優勢在于可在iOS設備上獨立完成越獄操作&#xff0c;Checkra1n則需要借助電腦&#xff0c;包括重啟失效后也是如此…

502 Bad Gateway The server returned an invalid or incomplete response

問題描述&#xff1a;最近在登陸某大學網站時&#xff0c;網站如下&#xff1a; https://yzb.tju.edu.cn/ 發現登錄不進去&#xff0c;報了502 Bad Gateway The server returned an invalid or incomplete response這個錯誤。 問題解決&#xff1a;將https改為http&#xff0…

iOS VIPER架構(三)

路由是實現模塊間解耦的一個有效工具。如果要進行組件化開發&#xff0c;路由是必不可少的一部分。目前iOS上絕大部分的路由工具都是基于URL匹配的&#xff0c;優缺點都很明顯。這篇文章里將會給出一個更加原生和安全的設計&#xff0c;這個設計的特點是&#xff1a; 路由時用p…

android camera滑動,Android怎么實現小米相機底部滑動指示器

Android怎么實現小米相機底部滑動指示器發布時間&#xff1a;2021-04-15 14:39:38來源&#xff1a;億速云閱讀&#xff1a;94作者&#xff1a;小新這篇文章給大家分享的是有關Android怎么實現小米相機底部滑動指示器的內容。小編覺得挺實用的&#xff0c;因此分享給大家做個參考…

laravel安裝laravel-ide-helper擴展進行代碼提示(二)

一、擴展的地址 https://github.com/barryvdh/laravel-ide-helper二、安裝擴展 1、引入庫&#xff1a; composer require barryvdh/laravel-ide-helper composer require doctrine/dbal如果只想在開發環境上使用&#xff0c;請加上--dev composer require --dev barryvdh/larav…

android md 顏色,安卓MD(Material Design)規范

Md規范是一種設計風格&#xff0c;并不特指規范。是一種模擬紙張的手法。一、核心思想把物理世界的體驗帶進屏幕。去掉現實中的雜質和隨機性&#xff0c;保留其最原始純凈的形態、空間關系、變化與過度&#xff0c;配合虛擬世界的靈活特性&#xff0c;還原最貼近真實的體驗&…

Mariadb修改root密碼

2019獨角獸企業重金招聘Python工程師標準>>> 默認情況下&#xff0c;新安裝的 mariadb 的密碼為空&#xff0c;在shell終端直接輸入 mysql 就能登陸數據庫。 如果是剛安裝第一次使用&#xff0c;請使用 mysql_secure_installation 命令初始化。 # mysql_secure_inst…

【譯】Googler如何解決編程問題

本文是Google工程師Steve Merritt的一篇博客&#xff0c;向大家介紹他自己和身邊的同事解決編程問題的方法。 原文地址&#xff1a;blog.usejournal.com/how-a-googl… 在本文中&#xff0c;我將完整的向你介紹一種解決編程問題的策略&#xff0c;這個策略是我在日常工作中一直…

自學html和css,學習HTML和CSS的5大理由

描述人們學習HTML和CSS最常見的原因是開始從事web開發。但并不是只有web開發人員才要學習HTML和CSS的核心技術。作為一個網絡用戶&#xff0c;你需要你掌握的相關技術很多&#xff0c;但下面有5個你無法拒絕學習HTML和CSS的理由。1、輕松制作卡通動畫Web上的動畫很多年來都是使…

html 左側 樹形菜單,vue左側菜單,樹形圖遞歸實現代碼

學習vue有一段時間了&#xff0c;最近使用vue做了一套后臺管理系統&#xff0c;左側菜單需求是這樣的&#xff0c;可以多層&#xff0c;數據由后臺傳遞。也因為自己對官方文檔的不熟悉使得自己踩了不少坑&#xff0c;今天寫出來和大家一起分享。效果圖如下所示&#xff1a;先說…

Node.js的基本使用3

koa(擴展知識&#xff0c; 建議學習) koa是express超集&#xff08;進階版&#xff09;前后端分離和耦合概念介紹 面向過程 -》 面向對象 --》 面向服務數據庫 Node.js mongodb(bson json的超集) 分類&#xff1a; 關系型數據庫&#xff1a; MySql非關系型數據庫: MongoDB Mong…

Flutter的滾動以及sliver約束

Flutter框架中有很多滾動的Widget,ListView、GridView等&#xff0c;這些Widget都是使用Scrollable配合Viewport來完成滾動的。我們來分析一下這個滾動效果是怎樣實現的。 Scrollable在滾動中的作用 Scrollable繼承自StatefulWidget&#xff0c;我們看一下他的State的build方法…

頁面增加html,為靜態頁面HTML增加session功能

一般來說&#xff0c;只有服務器端的CGI程序(ASP、PHP、JSP)具有session會話功能&#xff0c;用來保存用戶在網站期間(會話)的活動數據信息&#xff0c;而對于數量眾多的靜態頁面(HTML)來說&#xff0c;只能使用客戶端的cookies來保存臨時活動數據&#xff0c;但對于cookies的操…