如何将 Flex Mobile ActionBar 向下移动一点?
我试图简单地将 actionBar 向下移动 75 像素,这样我就可以在其中挤压 adMob 广告。
我尝试过:
navigator.actionBar.y=75;
但是,我在视觉上没有看到任何不同的东西,它没有移动,它没有给我任何错误,但如果我执行 trace(navigator.actionBar.y);
它声称它处于 75。 ...尽管它显然不在屏幕上。
有人有什么想法吗?另外,这仅适用于一个视图,我无法使用一种将操作栏在整个应用程序中向下移动的解决方案。我只需要它在这个特定的视图中向下移动。
谢谢!
编辑: @布莱恩, 感谢您的建议,几乎完成了整个混乱。我正在尝试在皮肤内创建一个函数来添加 adMob 广告的空间。但是,我认为我没有正确引用该函数,因为当我这样做时,我没有收到任何错误,并且什么也没有发生。
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" >
<!-- host component -->
<fx:Metadata>
[HostComponent("spark.components.ViewNavigator")]
</fx:Metadata>
<fx:Script>
<![CDATA[
public function adMobVisible(trueOrFalse:Boolean):void
{
if(trueOrFalse)
{
main_group.top=70;
}
else
{
main_group.top=0;
}
}
]]>
</fx:Script>
<!-- states -->
<s:states>
<s:State name="landscapeAndOverlay" />
<s:State name="portraitAndOverlay" />
<s:State name="landscape" />
<s:State name="portrait" />
<s:State name="disabled" />
<s:State name="normal" />
<!-- <s:State name="admob" /> -->
</s:states>
<s:VGroup id="main_group" width="100%" height="100%">
<s:ActionBar id="actionBar" width="100%" />
<s:Group id="contentGroup" width="100%" height="100%" />
</s:VGroup>
</s:Skin>
我做了:
import skins.AdMobHolderSkin;
protected var ad:AdMobHolderSkin = new AdMobHolderSkin();
在上面......然后我只是尝试做一件简单的事情,例如:
ad.adMobVisible(true);
但什么也没有发生。有什么想法吗?感谢您对此提供帮助。
I'm trying to simply move the actionBar down 75 pixels so I can squeeze an adMob ad in there.
I tried:
navigator.actionBar.y=75;
But, i'm not seeing anything different visually, it's not moving, it's giving me no errors, but if i do trace(navigator.actionBar.y);
it claims it's at 75....even though it's clearly not on the screen.
Does anyone have any ideas? Also, this would only be for ONE view, I can't use a solution that would move the action bar down throughout the entire application. I just need it moved down in THIS particular view.
Thanks!
EDIT:
@Brian,
Thanks for the suggestion, almost done this whole mess. I'm trying to make a function inside the skin to add the space for the adMob ad. But, I don't think im referencing the function correctly, because when i do it im not getting any errors, and nothing is happening.
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" >
<!-- host component -->
<fx:Metadata>
[HostComponent("spark.components.ViewNavigator")]
</fx:Metadata>
<fx:Script>
<![CDATA[
public function adMobVisible(trueOrFalse:Boolean):void
{
if(trueOrFalse)
{
main_group.top=70;
}
else
{
main_group.top=0;
}
}
]]>
</fx:Script>
<!-- states -->
<s:states>
<s:State name="landscapeAndOverlay" />
<s:State name="portraitAndOverlay" />
<s:State name="landscape" />
<s:State name="portrait" />
<s:State name="disabled" />
<s:State name="normal" />
<!-- <s:State name="admob" /> -->
</s:states>
<s:VGroup id="main_group" width="100%" height="100%">
<s:ActionBar id="actionBar" width="100%" />
<s:Group id="contentGroup" width="100%" height="100%" />
</s:VGroup>
</s:Skin>
I did:
import skins.AdMobHolderSkin;
protected var ad:AdMobHolderSkin = new AdMobHolderSkin();
up top... then I just tried to do a simple thing like:
ad.adMobVisible(true);
But nothing happens. Any ideas? Thanks for helping with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您检查
ViewNavigatorSkin
的代码,您会发现它使用简单的数学来布局其两个项目(ActionBar
和Group
)。换句话说,它没有使用布局容器,其中设置top
或y
会产生任何效果。相反,您需要设置
ViewNavigator
的外观。首先,定义皮肤(注意我如何在VGroup
中设置top="75"
:VNSkin.mxml
然后,在我的 main 内部应用程序中,我将设置 ViewNavigator 的外观以使用此外观:
MyApp.mxml
最后,在我的视图中,我需要设置状态并将其在视图激活和停用时放回:
MyView .mxml
注意这种技术会增加一些开销,因为您的
ViewNavigator
皮肤现在是 MXML 而不是纯 ActionScript 您可能会考虑基于ViewNavigatorSkin
源代码在纯 ActionScript 中创建皮肤,这样您就可以。 巨大影响,我不会担心它。可以将其与您的偏移量一起放置...但如果您没有注意到 MXML 皮肤对性能的
在写完答案后,我注意到您只想将其用于一个视图。我进行了修改,向
VNSkin
类添加一个状态,然后在视图代码中切换状态(viewActivate
和viewDeactivate
。对于记录,这一切感觉就像是一种黑客攻击,我会考虑某种通知机制,以便您可以与皮肤进行通信,以便以除此之外的方式进行更改......但我至少让您走上了一条道路。我很乐意看到有人来这里。并提出更好的建议,直到那时,你就有了可行的方法:PIf you inspect the code for
ViewNavigatorSkin
, you will find that it lays out its two items (ActionBar
andGroup
) using simple math. In other words, it is not using a layout container in which settingtop
ory
will have any effect.Instead, you need to skin the
ViewNavigator
. First, define the skin (notice how I set thetop="75"
in theVGroup
:VNSkin.mxml
Then, inside of my main application, I will skin the ViewNavigator to use this skin:
MyApp.mxml
Finally, in my view, I need to set the state and put it back when the view is activated and deactivated:
MyView.mxml
Note that this technique adds some overhead because your
ViewNavigator
skin is now MXML instead of pure ActionScript. You might consider creating a skin in pure ActionScript based off theViewNavigatorSkin
source code such that you can place it with your offset... but if you aren't noticing a huge performance hit from the MXML skin, I wouldn't worry about it.EDIT
I noticed after I wrote my answer that you only want it for one view. I have made a modification to add a state to the
VNSkin
class and then switch the states in the view code (viewActivate
andviewDeactivate
. For the record, this all feels like a hack. I'd consider some sort of notification mechanism so that you can communicate to the skin in order to change in a way other than this... but I have at least put you on a path to doing this with one technique. I'd love to see someone come here and suggest something better. Until then, you have something that works :P