Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Android xml layout to png/svg to use in iOS version

I have an Android layout xml file here:

<?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>

This xml layout renders to look like this:

Pin layout xml screenshot

This works fine for android but I want to use this xml layout on the iOS app as well. I was wondering if there was a way to convert this xml layout to a svg or png format or anything that would allow me to re-use this item without needing to re-create it. It needs to have transparency and a .svg would most likely be better than a .png if that works. I would like only the displayed visible part to be clickable if possible.

like image 356
Pat Myron Avatar asked Sep 16 '15 16:09

Pat Myron


1 Answers

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.

like image 61
Fattie Avatar answered Oct 16 '22 19:10

Fattie