如何将Android xml布局转换为png/svg以在iOS版本中使用

Pat*_*ron 5 xml svg png android ios

我这里有一个Android布局xml文件:

<?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>
Run Code Online (Sandbox Code Playgroud)

此xml布局呈现如下所示:

引脚布局xml截图

这适用于Android,但我想在iOS应用程序上使用此xml布局.我想知道是否有办法将此xml布局转换为svg或png格式或任何允许我重新使用此项而无需重新创建它的方法.它需要具有透明度,如果可行的话,.svg很可能比.png更好.如果可能的话,我希望只显示可见部分.

Fat*_*tie 5

iOS中的等效技术是Apple的"自动布局"系统.

一旦掌握了它,它就很容易使用; 事实是,就像任何事情一样,这是一个专业的事情.当然,你可以制作一个透明的PNG并将其用作UIButton的图像.

我真的建议在Apple中使用"UIButton",并使用颜色等,直到你看起来没问题 - 尽管与其他平台不同.

两个关键点是

  1. 从技术上讲,在不同平台上使应用看起来几乎是不可能的

  2. 几乎每个人都同意你不应该试着这样做; 除了在游戏中,允许按钮等元素在每个平台/ os版本上都是"自然的".

顺便说一下,我不知道为什么有人会对你的问题进行投票.跨平台问题是当今发展中最关键的问题之一.