Are we allowed to use xml layout in KMM? using xml in KMM will affect its functionality?
Because when i create project for KMM, android studio automatically creates using jetpack compose. Does it mean that we can only or should use jetpack compose for KMM.
in places like
setContentView(R.layout.activity_main)
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.new_layout,null);
etc
Of course you can use XML, the kmm framework just shares common business logic code, not shared UI。
Android platform you can still use xml, IOS platform you can choose swift or object c。
Related
I am currently developing an app that I want to release for Android and IOS. My problem is that I don't want to use Material Design for both platforms, as that wouldn't match the IOS design language. Is there any way to use one codebase and compile it for Android using Material Design and for IOS using Cupertino? If not, what is the usual way to go?
Checkout: https://pub.dev/packages/flutter_platform_widgets
Its a library that has already done this for a bunch of widgets. If the library doesn't have something you want you can make use of the PlatformWidget from the library. Under the hood it will be doing something similar to fartem's answer.
You can build widgets tree with platform separation or move your widgets to a separated classes/files. Example:
Example with just if:
if (Platform.isAndroid) {
return Column(
// Android specific layout
);
} else {
return Column(
// iOS specific layout
);
}
Use "flutter_platform_widgets" where you can separate each widgets to Android & IOS
The new Jetpack compose component added to Arch component is like Flutter Ui making.
How does it make the Ui though?
Does it use a native code engine like Skia, or it still follows the ViewGroup way like before?
Compose creates one view currently named AndroidComposeView, which inherits ViewGroup, and it draws the widget tree on its canvas. It also processes motion/keyboard events for this view.
There may be more helper views added to this view due to implementation details, but basically for the "widgets" of Compose, you won't see classical Views in view hierarchy. Layout inspector currently doesn't help for Compose - you can try it but you'll won't see your widgets.
Developers are promised to be able to create own customized widgets, which can directly paint on Canvas, set layout for itself or children, or process input events.
However, the Canvas and lots of other classes used here are not standard framework classes. For example, Canvas for Compose is redefined in Kotlin. Similar way there is new Paint, Shape, and other new classes. They internally use framework classes for their work, but that's implementation detail. When drawing, you'd use these new classes.
Since Compose is a library, and not present natively on Android devices, the library is included in each app that uses Compose.
Also there is no native code involved here, all is done in Kotlin and becomes part of your app's dexed code. By using Compose, your app won't contain any additional native library (probably, if creators don't change mind).
No, It doesn't use anything from the old UI Toolkit actually they are building it to overcome old UIToolkit's problems.
Compose is not views, It's a new set of Jetpack UI Widget, Basically, it's a Kotlin compiler plugin which renders the Android Canvas (I suppose there's no documentation for this yet) with full compatibility of existing android's view system, the last Dev summit there was a talk covers how it works internally, I/O had another talk too
I've developed an android library which exposes some activities, include one named AuthenticiateActivity and also included some helper classes.
I have a second android project that pulls in this library. I am trying create a custom React Native UI component to be able to display the AuthenticateActivity using javascript.
I have followed as best I can the documentation on creating native UI components here, however my use case is slightly different. As I understand, I need to create a ViewManager that extends SimpleViewManager, however, the SimpleViewManager takes a custom view class as a generic parameter. In my case I'm simply trying to display the activity defined in the library, I'm not looking to create a fully custom View implementation.
Any ideas how I can achieve this?
For displaying a completely new Activity you should just use a native module.
There's a good example that shows how to wrap a custom Activity.
I would like to know if there is any equivalent to UserControl in Xamarin.Android using the MvvmCross framework. Because I have a MvxActivity containing a layout I would like to reuse in several Views. And I don't know how to call it in my these several views.
If you have any idea...
Thanks for any help !
You could try the MvxFrameControl at the end of N=26 in http://mvvmcross.blogspot.co.uk/
The source code for MvxFrameControl also shows you how to inherit from any Android control in order to add data-binding capabilities - see https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views/MvxFrameControl.cs
Java is used to bring up gui components like View and Widgets. Official site say they dont include AWT/Swing as a part of their java bundle, then what implementation (native-wrapper if any?) they have in place? Also is it possible to create user interface from scratch for android apps without extending any View class?
It's a custom UI toolkit unrelated to AWT or Swing.
You can create custom subclasses of the View class to draw whatever custom components you would like, but most of the time you can set attributes on the existing components to change the way they're drawn (like setting the drawables for a button).