i have to show map view in rounded shape , is it posible to show android map view with rounded shape.
I have tried to applying fragment layout gadient but after map loading is showing rectange view.
any guidence for to make android rounded mapview
Yes, it possible. Cover the MapFragment with another layout, and set for this layout a 9-patch background, that will cover it the way you want, take a look at this question I asked on the same topic not long ago:
Is there a way to implement rounded corners to a Mapfragment?
You can use shapes in layer-list
here is the shape_circle.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="#drawable/shape_circle_rect"/>
<item android:drawable="#drawable/shape_circle_oval"/>
</layer-list>
shape_circle_rect.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#android:color/transparent"/>
<stroke android:width="50dp" android:color="#ffffff"/>
<padding
android:left="-50dp"
android:top="-50dp"
android:right="-50dp"
android:bottom="-50dp"/>
</shape>
shape_circle_oval.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<stroke android:color="#ffffff" android:width="100dp"/>
<solid android:color="#android:color/transparent"/>
</shape>
and Custom Map Fragment
public class MapFragment extends SupportMapFragment{
//...
//Some methods, set up map and etc.
//...
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
View mapView = super.onCreateView(inflater, viewGroup, bundle);
RelativeLayout view = new RelativeLayout(getActivity());
view.addView(mapView, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
FrameLayout frameLayout=new FrameLayout(getActivity());
frameLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
frameLayout.setBackgroundResource(R.drawable.shape_circle);
view.addView(frameLayout);
return view;
}
//...
//...
}
Related
In a Flex mobile app I have 5 Views, handling OAuth logins through 5 different social networks - including Google+ and Facebook. The Views are being selected through the menu shown below:
The filenames are FB.mxml, GG.mxml, MR.mxml, OK.mxml, VK.mxml and their source code looks very similar:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
viewActivate="loadInfo(event)"
viewDeactivate="closeSWV(event)"
title="Facebook.com">
....
private function closeSWV(event:Event=null):void {
_busy.visible = _busy.includeInLayout = false;
_reload.visible = _reload.includeInLayout = true;
stage.removeEventListener(Event.RESIZE, resizeSWV);
if (! _swv)
return;
_swv.removeEventListener(Event.COMPLETE, extractAccessToken);
_swv.removeEventListener(LocationChangeEvent.LOCATION_CHANGE, extractAccessToken);
_swv.removeEventListener(IOErrorEvent.IO_ERROR, closeSWV);
_swv.removeEventListener(ErrorEvent.ERROR, closeSWV);
_swv.dispose();
_swv = null;
}
private function resizeSWV(event:Event=null):void {
if (! _swv)
return;
// align to the right-bottom corner
_swv.viewPort = new Rectangle(stage.stageWidth - Preferans.SCALE * width,
stage.stageHeight - Preferans.SCALE * height,
Preferans.SCALE * width,
Preferans.SCALE * height);
}
....
<s:VGroup>
<s:Label id="_first" fontWeight="bold" text="Your name:" />
<s:Label id="_gender" fontWeight="bold" text="Gender:" />
<s:Label id="_city" fontWeight="bold" text="City:" />
</s:VGroup>
<s:Button id="_play"
label="Play"
click="startGame(event)"
includeInLayout="false"
visible="false" />
</s:View>
My problem is: The 5 mxml files listed above have many similar methods and variables and UI elements and only few different methods and variables.
I've tried to introduce a "base class" for them all several times already and have always given up, because it is not straightforward for mxml files (versus pure AS3 classes).
Does anybody please have an idea, how to approach this?
You can define an abstract class that extends the UI component that you want to use in each row of the list. In your case, it will extend View.
package your.package{
public class SocialAccountView extends View{
// in this class you can add the generic methods
// that you want the view to have
}
}
After that, in the mxml file you can use the class you created as the main type instead of View
<your.package:SocialAccountView
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
viewActivate="loadInfo(event)"
viewDeactivate="closeSWV(event)"
title="Facebook.com">
</your.package:SocialAccountView>
With this you know that all the items in the list are of that type, and have the methods of the parent class. You can even override methods in each view.
Regarding the UI components, the maximum abstraction level (that I am aware of) you can have with them is to build an extra component and use it in all views. Something like...
Labels.mxml
<s:VGroup>
<s:Label id="_first" fontWeight="bold" text="Your name:" />
<s:Label id="_gender" fontWeight="bold" text="Gender:" />
<s:Label id="_city" fontWeight="bold" text="City:" />
</s:VGroup>
and then use it in each component like
<your.package:Labels
id="labelsComponent"/>
Hope this helps.
applicationX.mxml :
<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160" >
<s:ViewNavigator label="Login" width="100%" height="100%" firstView="views.LoginView" />
<s:ViewNavigator label="Settings" width="100%" height="100%" firstView="views.SettingsView" />
</s:TabbedViewNavigatorApplication>
Settings.mxm ( Settings View ) :
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" >
<s:Label id="myLabel" />
</View>
How to access myLabel from Login view ?
you shouldn't. One view should never know what is inside another view. What you want is a model with a property like .loginStatus that can then be set by Login and seen by Settings. You can use one of many MVC styles to accomplish this. Do some googling on MVC patterns and Flex and see the different ways this is done. In the meantime, here is a quick for instance:
Settings.mxml:
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" >
<fx:Script>
<![CDATA[
private var model:MyModel = MyModel.getInstance();
]]>
</fx:Script>
<s:Label id="myLabel" text="{model.loggedInStatus}" />
</View>
Login.mxml:
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" >
<fx:Script>
<![CDATA[
private var model:MyModel = MyModel.getInstance();
private function loginSucceded():void{
model.loggedInStatus="Logged In";
}
]]>
</fx:Script>
</View>
MyModel.as
Singleton class with a property named .loggedInStatus. You can check this other answer AS3 singleton implementations for a discussion about various singleton patterns and why I use the one I use.
This is a VERY simple example. You wouldn't want to use a human readable string loggedInStatus to determine state or anything. but this is an example of how the model works and how views can display proper things based on the state of the model.
Set settings singleton. This means, you define a static variable pointing to the item itself (it is required to have only one instance of Settings.mxml)
add
public static var instance:Settings;
to settings.
add initializeEventListener to settings, and inside the function set the instance:
instance=this;
Than you can access Settings page anytime by getting the singleton, like:
Settings.instance.myLabel.text="success";
I cannot extend Office 2010 UI even when I use the code from MSDN. This is the code I think should work:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<backstage>
<tab idMso="TabShare">
<firstColumn>
<taskFormGroup idMso="GroupShare">
<category idMso="FileTypes">
<task id="tskExportXmlCms" label="Exportovat jako XML">
<group id="grpExportXmlCms" label="Exportovat jako XML">
<topItems>
<button id="btnExportXmlCms" label="Exportovat jako XML" onAction="OnExportXmlCms" />
</topItems>
</group>
</task>
</category>
</taskFormGroup>
</firstColumn>
</tab>
</backstage>
</customUI>
public void OnExportXmlCms(IRibbonControl control) { }
When I add Ribbon (Visual Designer) I can see added items. When I use Ribbin (XML) I'm not able to see anything in the backstage. What is wrong?
There was missing this method:
public partial class ThisAddIn {
protected override Office.IRibbonExtensibility CreateRibbonExtensibilityObject() {
return new Ribbon();
}
}
I would like to know if it's possible to skin view for my Flex mobile application :
My ActivityView.as
public class ActivityView extends View
My ActivityViewSkin.mxml (It skin associated)
<?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">
<fx:Metadata>
[HostComponent("com.corp.views.activity.ActivityView")]
...
It's a good way for mobile development ?
And how can I use this in this skin :
<s:navigationContent>
Thank you very much !
Anthony
no.
Spark skin is not optimized for mobile. you should use MobileSkin . (Action script only).
I have been looking for similar information, however everything I can deduce from documentation and blogs implies that MobileSkin is something you do for component-level skinning (e.g. buttons, lists, itemRenderers, etc.), things that would be used many times throughout the app.
THe other reason to think you might be able to get away with skinning your View via MXML is that all the Views I have seen code for are done so declaratively (MXML) and by skinning the View subclass using just the Skin class, you are only adding one more layer of hierarchy via the contentGroup in most skinnableContainer skins.
If you are using spark.components.View, then you are using a skin associated with as it is a SkinnableContainer. It is NOT a simple group as you might think.
I dunno, I am kinda at a loss as to where to focus my efforts. I am sure performance implications (if any) will rear their heads way later in the development stage.
From experience so far, you don't skin the View. You skin the ViewNavigatorApplication. First, create the custom skin:
public class DViewNavigatorApplicationSkin extends ViewNavigatorApplicationSkin
{
[Embed(source="assets/wine_240.jpg")]
protected var cornerImage:Class;
public function DViewNavigatorApplicationSkin()
{
super();
}
override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
{
graphics.beginFill(0x000000);
graphics.drawRect(0,0, unscaledWidth, unscaledHeight);
graphics.endFill();
var ba:BitmapAsset = new cornerImage() as BitmapAsset;
var translateMatrix:Matrix = new Matrix();
translateMatrix.tx = unscaledWidth - ba.width;
translateMatrix.ty = unscaledHeight - ba.height;
graphics.beginBitmapFill(ba.bitmapData, translateMatrix);
graphics.drawRect(unscaledWidth - ba.width + 1, unscaledHeight - ba.height + 1, ba.width, ba.height);
graphics.endFill();
}
The contents of drawBackground docks the image to the lower right-hand corner of the display. You can draw anything in this function.
Then in the theme.css:
s|ViewNavigatorApplication
{
color: #ffffff;
focusColor: #ff9999;
skinClass: ClassReference("com.domain.skins.mobile.ThemeName.DViewNavigatorApplicationSkin");
}
s|View
{
backgroundAlpha: 0;
}
You draw the background image on the application itself. You then make the View totally transparent so that you can see the background image through it.
It may be possible to skin each individual view, but so far, it seems more practical to skin the application instead.
It is kinda late to answer this question. Actually, we can use Spark Skin to skin the View component without any problem. View is just a subclass of SkinnableContainer (which is subclass of SkinnableComponent) so by default, whatever content you add directly to the MXML of View component will be added to contenGroup of SkinnableContainer.
I have added an example to skin the View using Spark Skin:
Main Application:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160">
<fx:Script>
<![CDATA[
import com.accessdigital.core.SimpleView;
]]>
</fx:Script>
<fx:Style>
#namespace s "library://ns.adobe.com/flex/spark";
#namespace core "com.accessdigital.core.*";
core|SimpleView{
skinClass : ClassReference("skin.view.Skin_SimpleView");
}
</fx:Style>
<s:ViewNavigator width="100%" height="100%"
firstView="{SimpleView}">
</s:ViewNavigator>
</s:Application>
View Class
public class SimpleView extends View
{
public function SimpleView()
{
super();
}
[SkinPart(required="true")]
public var myButton:Button;
override protected function createChildren():void{
super.createChildren();
var anotherButton:Button = new Button();
anotherButton.label = "Another button";
anotherButton.addEventListener(MouseEvent.CLICK, onAnotherButtonClick);
if(!actionContent){
actionContent = [];
}
actionContent.push(anotherButton);
}
protected function onAnotherButtonClick(event:MouseEvent):void
{
trace("This is another button");
}
override protected function partAdded(partName:String, instance:Object):void{
super.partAdded(partName, instance);
if(instance == myButton){
myButton.addEventListener(MouseEvent.CLICK, onButtonClick);
}
}
protected function onButtonClick(event:MouseEvent):void
{
trace("This is a simple button");
}
}
Skin File:
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<!-- host component -->
<fx:Metadata>
[HostComponent("com.accessdigital.core.SimpleView")]
</fx:Metadata>
<!-- states -->
<s:states>
<s:State name="disabled" />
<s:State name="normal" />
</s:states>
<!-- SkinParts
name=myButton, type=spark.components.Button, required=true
name=contentGroup, type=spark.components.Group, required=false
-->
<s:Rect width="100%" height="100%">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="#666666"/>
<s:GradientEntry color="#222222"/>
</s:LinearGradient>
</s:fill>
</s:Rect>
<s:Group id="contentGroup" width="100%" height="100%">
<s:Button id="myButton" label="My Button" horizontalCenter="0" verticalCenter="0"/>
</s:Group>
</s:Skin>
Hope it helps
I have not completly understood how custom components work...
Let's assume I have my Main.mxml application
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:local="*">
<fx:Script>
<![CDATA[
private var privateStr:String = "Stringa Private";
public var publicStr:String = "Stringa Public";
]]>
</fx:Script>
<local:AddUser height="100" width="500"/>
<s:Label id="lblText" x="120" y="120" width="418" height="115" text="!!!"/>
</s:WindowedApplication>
And the component AddUser.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="initialize_component()">
<fx:Script>
<![CDATA[
public var btnName:String = "Login";
private function initialize_component():void
{
login.label = btnName;
}
private function doLogin():void
{
//some stuff here
}
]]>
</fx:Script>
<s:TextInput id="txtuser" x="96" y="36"/>
<s:TextInput id="txtpass" x="96" y="66"/>
<s:Button id="login" x="96" y="96" width="128" click="doLogin()" />
</mx:VBox>
I would like that on the Button (login) click I get the publicStr/privateStr that are in the main.mxml...
Am I getting everything wrong? how can I use more components like they are all part of the same application and use the same variables/methods?
It seems like you're having issues with the idea of encapsulation. Child components shouldn't know about parent components, and View components shouldn't do real work, only request work from Controller components. In very simple projects, your top level component can contain the controller logic, but many people prefer to keep it separate even in small projects. How to do this is beyond the scope of this answer.
So, how should the parent and child properly communicate? Child components should expose properties that the parent (or Framework, if you're feeling ready to use a dependency injection framework) can populate with only the data the child components need.
Child components request work from the controller by generating events.
So, doLogin() would containe something like
dispatchEvent(new Event('doLogin'));
and the parent component would be listening for this Event. In its handler, you would perform the login. More than likely, your login would be asynchronous, so you'll need another handler to listen for the login data to come back. When the login data comes back, you will then set the properties on the login View based on the return.