A memorandum when people who came with Swift touch Kotlin Pick up places that are likely to stumble due to differences in concept
** drawable **, ** layout **, ** values ** under res ** kotlin ** under java (not test)
** drawable **: assets in ios, but can also save settings like css ** layout **: storyboard in iOS ** values **: A place where properties in ios are saved together in a struct etc. You can see it by looking at the color code, in-app text, etc. ** kotlin **: Contains the viewController file in Activity-ios
** Story Board ** in ** Xcode ** ** activity.xml ** in Android Studio **
Parented by ConstraintLayout, LinerLayout, and TableLayout (layout base) I will fill in the parts and make a layout.
iOS
obj.frame.size.width / 2
obj.center.x(y)
//Center Vertical and Horizontal for storyboards
Android
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
parent is the parent element. Constraints the right side of the specified element to the right side of the parent element and the left side to the left side. If this is set to "@ id / part id", it can be set for the specified element. Due to the ** equal ** constraints on the left and right, the left and right force relationships of the parts are equal and placed in the middle.
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="10dp"
If you add the third line like this, the power relationship will collapse and margin10dp will be on the right. Shift 10dp to the left.
iOS podfile(cocoapods) Android Gradle Installation (pod install in ios) Click the elephant mark (Sync Project with Cradle Files) in the execution menu
iOS performsegue, navigationController, etc. Android Screen movement Transition with ** startActivity ** using ** Intent instance ** Return finish() Since startActivity creates a new activity instance, Close (return) the screen with finish () unless there is a special reason
(Of course there are others, but at the moment we have implemented only the minimum required Only this is introduced)
segment control Since android does not have this, is it an override of RadioButton? Need to substitute with a button
import Since it can be used on iOS without importing UI parts, I'm unknowingly creating an instance, On Android, I'll install them one by one.
For example, in the case of Button, if you press enter when completion appears, import will be automatically entered. Otherwise it will be imported with option + Enter
If you are accustomed to replacement, I think you can use Kotlin for java articles as well. Those who do not may find it useful. When I paste the java code into the editor, I'm asked if I want to convert it to Kotlin Convenient because there are few articles on Kotlin
In Swift, it is declared with "?", But In Kotlin, add lateinit in addition to that
when Switch in iOS There is no when in iOS, so why not! Note that it may be when(int) { 1 -> println("int is 1") 2 -> println("int is 2") } Can be used like a Switch statement
What did you think? If you are used to Swift to some extent, if you can understand the layout part I think it can go smoothly to some extent. I'm glad if you can use it as a reference. If you find any mistakes, please point them out and we will correct them immediately.