androidiosxmlsvgpng

Convert Android xml layout to png/svg for iOS


Android layout/*.xml file:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/locationMarker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="30dp"
        android:gravity="center"
        android:orientation="vertical">

        <TextView
            android:id="@+id/locationMarkertext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/rounded_corner_map"
            android:gravity="center"
            android:minWidth="180dp"
            android:onClick="create"
            android:paddingLeft="2dp"
            android:paddingRight="2dp"
            android:text="Pick the Location"
            android:textColor="@android:color/white" />

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:onClick="create"
            android:src="@drawable/plus" />
    </LinearLayout>

renders this:

Pin layout xml screenshot

I want to reuse that for iOS. Can that be exported to other formats (.svg, .png, etc) for re-use without re-creation? It needs transparency and .svg seems preferable to .png. I'd like only the displayed visible part to be clickable too.


Solution

  • The equivalent technology in iOS is Apple's "autolayout" system.

    It's quite easy to use once you get the hang of it; the fact is though like anything it's a specialist thing. And sure, you could just make a transparent PNG and use that as an image for a UIButton.

    I would really suggest just using a "UIButton" in Apple, and play with the colors etc until you get a look that is OK -- although not identical to the other platform.

    The two key points are

    1. it's almost impossible, technically, to make apps look identical on different platforms

    2. pretty much everyone agrees you should not try to do that; other than in games, allow elements like buttons etc. to be "natural" on each platform / os version.

    BTW I have no idea why anyone would downvote your question. Cross-platform issues are one of the most critical in development today.