1、上面的标题过多,我们选择的方法是让TabBar显示有限的标题
2、TabBar的每一项的宽度(Button的宽度)都是根据标题的长度来设置的,超出的部分不现实
<s:Group id="myContainer" height="100%" clipAndEnableScrolling="true"
width="{this.width-50}">
<s:TabBar id="menuBar" dataProvider="{source}" alpha="1" skinClass="components.tabbar.TabBarSkin_Scroll" click="menuBar_clickHandler(event)"/>
</s:Group>
3、四个移动思想的代码
/*
往右移动
坐标(负的)+当前总长度>窗口
原来坐标+视口-(坐标(负的)+当前总长度)
*/
private function checkRight():void{
var index:int=menuBar.selectedIndex;
var maxIndex:int=this.source.length-1;
if(index==maxIndex){
return;
}
index++;
menuBar.selectedIndex=index;
var sum:Number=0;//长度
for(var i:int=0;i<=index;i++){
sum+=FlexGlobals.topLevelApplication.itemWidthArr[i];
}
if((sum+menuBar.x)>myContainer.width){
menuBar.move(menuBar.x+myContainer.width-(sum+menuBar.x),menuBar.y);
}
}
private function checkLeft():void{
/*
往左移动
坐标(负的)+当前总长度<当前选择的索引长度
原来坐标+当前选择的索引长度-(坐标(负的)+当前总长度)
*/
var index:int=menuBar.selectedIndex;
if(index<1){
return;
}
var maxIndex:int=this.source.length-1;
index--;
menuBar.selectedIndex=index;
var sum:Number=0;//长度
for(var i:int=0;i<=index;i++){
sum+=FlexGlobals.topLevelApplication.itemWidthArr[i];
}
if((sum+menuBar.x)<FlexGlobals.topLevelApplication.itemWidthArr[i]){
menuBar.move(menuBar.x+FlexGlobals.topLevelApplication.itemWidthArr[i]-(sum+menuBar.x),menuBar.y);
}
}
private function checkFirst():void{
/*
选择第一个
*/
if(menuBar.selectedIndex==0){
if(menuBar.x!=0){
menuBar.move(0,menuBar.y);
}
}
}
private function checkLast():void{
/*
选择第一个
*/
if(menuBar.selectedIndex==source.length){
if(menuBar.x!=(myContainer.width-menuBar.width)){
menuBar.move(0,myContainer.width-menuBar.width);
}
}
}
4、时间有限,有问题留言哈,详细代码附件 。
5、如果您有更好的解决方案或代码有缺陷的地方,望告之,一定虚心接受,谢谢。
- 大小: 4.1 KB
分享到:
相关推荐
flex4 TabBar skin
NULL 博文链接:https://jzzwy.iteye.com/blog/1738561
Sample-Flex4-TabBar使用例子。
1、TabActivity实现底部Tabbar 2、Fragment底部实现 3、ViewPager Tabbar滑动式心啊
1、使用TabActivity实现Tabbar 2、使用Fragment实现Tabbar 3、ViewPager实现可滑动Tabbar
纯代码实现的TabBar,可以根据需要修改TabBar的大小,图片,背影色,任意添加TabBarItem的个数
IOS实现中间凸起圆形TabBar,类似于闲鱼的效果
tabbar上按钮位置控制,tabbar按钮实现居中
几代码实现导航栏透明渐变、实现TabBar中间凸起;可自定义
swift实现tabbar.zip,AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion - ...
flex tab bar samples
这是一个自定义的TabBar样式,实现TabBar中间凸起“ ”按钮
ios TabBar + Navigation纯代码实现 还有许多小例子在代码里
著名的flex-tabbar 使用 TabBar 为 famo.us 提供的 TabBar 小部件演示。 教程 建造 要构建演示,请确保全局安装了 grunt、webpack 和 webpack-dev-server: npm install -g grunt npm install -g webpack npm ...
tabBar 中间突出 push 方式 实现
3、实现自由组合tabBar菜单项目,支持自由组合总数超过5个tabBar菜单。 4、本示例是7个底部导航,分2种权限,权限1显示1,2,3;权限2显示4,5,6,7; 5、你也可以根据自己随便组合显示导航,比如1,3,5;2,4,6...
使用TabActivity实现底部Tabbar
自定义tabbar的功能 实现页面切换 按钮自定义回调 可真机或模拟器运行
小程序tabbar素材小程序tabbar素材小程序tabbar素材小程序tabbar素材 微信小程序tabbar小图片