hi am doing one application here I have to display some editexts and buttons....so some functions through cocos2d not feasible so I want integrate my android code to cocos2d code.I searched net in iphone its possible using addsubview() but android I don't have any idea pls any one can save me... thanks
in iphone using below code they added subview:
UIView *myview=[[UIView alloc] initWithFrame: CGRectMake(0, 0,320,480)];
myview.backgroundColor=[UIColor redColor];
[[[CCDirector sharedDirector] openGLView] addSubview:myview];
[myview release];
You can add view in cocos2d game activity as
TextView txv=new TextView(GameActivity.context);
txv.setText("ABC");
LayoutParams layoutParams =new LayoutParams();
CCDirector.sharedDirector().getActivity().addContentView(txv,layoutParams);
Related
I am developing panorama application and I cannot find some ways to implement my Android layouts or Android widgets(TextView, ImageView etc.) to my scene on ViroView.
Is it possible to do in this 3rd party library(ViroCore)?
Thanks, a lot!
first you need to inflate the view , then create an AndoridViewTexture ,and finally use the function attachview and give it the inflated view as a parm.
AndroidViewTexture androidTexture = new AndroidViewTexture(viroView.provideView(), pxWidth, pxHeight, isAccelerated);
androidTexture.attachView(inflated);
I'm new to StackOverflow community!
I need help with one problem with android in Xamarin Forms. To be precise... I tried with some friends to build our first app. We choose(with the help of our University professor) Xamarin for the cross-platform development of Android and iOS for both systems using the Xamarin Forms. I created the interface part of the app and now I am stuck in a fort with big walls. When I try to add a Tabbed Page the icon for the functional bar, the app crashes(Android) but in iOS, the problem doesn't appear...
I'd try with some solution... like :
-Render in the NameApp.Droid adds different renderer only for the android part but no result...
-Try another way to insert the icon in the .xaml file directly but no result...
-Try to follow another way to modify the .axam file for the "Theme" part
but no result...
I want to integrate all the stuff on time only in the "Main Project". I don't want for now touch the "nameProject.Droid" or "nameProject.iOS" part, But try to make in one shoot both(Andriod & iOS). I've found a different bug in Android (è.é) but for this, I am going crazy...
But I need to modify the ".Droid" no problem I accept the challenge!
This is the result I aspire to create.
"https://storage.googleapis.com/material-design/publish/material_v_12/assets/0B6Okdz75tqQsbHJuWi04N0ZIc0E/components-tabs-usage-mobile7.png"
This is the way I add the Icon in the Tabbed Page. An assumption I add all the stuff in the "Resource" in ".Droid" and ".iOS :
var MainPageTabbed = new MPageTabbed();
var Profile = new Profile();
var ListChat = new ListChat();
if (Device.RuntimePlatform == Device.Android)
{
MainPageTabbed.Icon = "ldpi.png";
Profile.Icon = "ldpi2.png";
Chat.Icon = "ldpi1.png";
}
if (Device.RuntimePlatform == Device.iOS)
{
MainPageTabbed.Icon = "ldpi.png";
Profile.Icon = "ldpi2.png";
ListChat.Icon = "ldpi1.png";
}
NavigationPage.SetHasNavigationBar(this, false);
Children.Add(MainPageTabbed);
Children.Add(Profile);
Children.Add(ListChat);
Someone can help me please to find a solution?
Here you have an example of how to use the TabbedPage in xamarin forms:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/tabbed-page/
... Xamarin.forms renders Android tabbed-pages as something called a viewpager combined with a TabPagerStrib, and it looks like the example in the link above.
You might read about BottomNavigationBar for Android instead, or look at this link for a TabPagerStrip with an image:
https://forums.xamarin.com/discussion/39937/adding-icons-to-a-pagertabstrip-instead-of-text
If anyone is interested in a FontAwesome custom icon implementation I followed this tutorial to begin with: FontAwesome with Xamarin Forms
Unfortunately he doesn't give an example of integrating with tabbed pages but after some experimenting I finally figured out a simplified Xaml way to render it without a custom tabbed renderer:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:IBMobile.Views"
xmlns:local2="clr-namespace:FontAwesome"
x:Class="IBMobile.Views.HomePage"
Visual="Material">
<ContentPage.IconImageSource>
<FontImageSource FontFamily="{StaticResource FontAwesomeSolid}" Glyph="{x:Static local2:IconFont.Home}" />
</ContentPage.IconImageSource>
Am I able to access UIKit through Nativescript or what ever the equivalent would be in Android directly from NativeScript code? For example, if I wanted to add a drop shadow to a UIView and add this view to the screen, would I be able to create a new UIView and programmatically add a drop-shadow if it's not supported in the XML and CSS implementations? I know they are supposed to have a 100% parody of the Native API's so it should be possible but just want to make sure as I'm having trouble finding examples in the docs.
Yes, you have full access to native objects for both iOS and android.
For example (taken from http://docs.nativescript.org/runtimes/ios/Overview.html):
Obj-C
UIView *view1 = [[UIView alloc] init];
// Or with the short-cut
UIView *view2 = [UIView new];
JS equivalent
var view1 = UIView.alloc().init();
// Or with the short-cut
var view2 = UIView.new();
Look around the runtime references in the docs as there are other examples of how do you operate with native objects for iOS/Android
I want to display several widgets with dynamic size in a flowlayout fashion, but I can't seem to find a flowlayout. Is it really no flowlayout in Xamarin for Android as part of the framework?
No,there is not flowlayout in Xamarin Android as far as I know.
Came across this implementation
http://slodge.blogspot.no/2013/01/an-mono-for-android-wrappanelflowlayout.html
which suits my needs perfectly.
In Xamarin Android FlowLayout available. Install nuget package AndroidFlowLayout by Dennis Daume. Make xaml like this
<org.apmem.tools.layouts.FlowLayout
android:id="#+id/ControlPanel"
android:padding="0dp"
android:includeFontPadding="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
Aceess your flow layout in .cs page & add controls as many you need. Even your can add controls from xaml too.
var flaout = view.FindViewById<FlowLayout>(Resource.Id.ControlPanel);
foreach (var item in SenderData)
{
var checkbox = new CheckBox(Context);
checkbox.SetCompoundDrawablesWithIntrinsicBounds(Resource.Color.DimGray, 0, 0, 0);
checkbox.Id = Convert.ToInt32(mailList.Value);
checkbox.Text=item.Name
checkbox.ScaleY = 0.8f;
checkbox.ScaleX = 0.9f;
flaout.AddView(checkbox);
}
There's also this from Jason Smith from Xamarin, for Xamarin.Forms:
WrapLayout.cs
It's the code from this talk from Xamarin Evolve 16.
I believe what you are looking for is called the FlexLayout, introduced with Xamarin.Forms version 3.0:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/flex-layout
I am trying to build an Android application with PhoneGap.
I need to be able to use the PhoneGap WebView (super.appView) and all of its javascript magic but I also need to display some native UI controls around the WebView.
This post goes part way to providing a solution Android PhoneGap Plugin, UI tabbar, resize WebView
Has anyone managed to implement PhoneGap with a native UI?
I will also be using a GestureOverlayView but thats another story ;)
Answer:
super.onCreate(savedInstanceState);
//creates super.appView and calls setContentView(root) in DroidGap.java
init();
//just an empty LinearLayout
layoutId = R.layout.blank;
view = new LinearLayout(this);
setContentView(layoutId);
view.addView(your_component_here);
view.addView((View) appView.getParent()); //adds the PhoneGap browser at index 1
//accesses the browser at index 1. Tells browser to not fill view
view.getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
setContentView(view);
I would struggle to tell you how this works, all I can tell you is that it does and it is all my own work.
Setting the view to a different colour can help you to see what is going on too....
view.setBackgroundColor(Color.BLUE);
Working with PhoneGap-1.0.0.jar the latest release so far.
A more cleaner approach:
super.onCreate(savedInstanceState);
// Create native view with UI controls.
View header = View.inflate(getContext(), R.layout.header, null);
// PhoneGaps WebView is located inside a LinearLayout.
// The protected (and therefore inherited) variable root
// references this LinearLayout. Add your native Views
// to this variable.
root.addView(header);
// Create WebView and add it automatically to the LinearLayout.
super.loadUrl("file:///android_asset/www/index.html");
Yes, you can embed native controls within HTML by using the plugin.
Call the native method which contains your native view from HTML page using plugin.
e.g. window.plugins.anatomyPlugin.showAudio();
I use this for showing audio player design in native.
This guide from PhoneGap may be helpful.