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

6

我这里有一个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>

这个xml布局会被渲染成这样:

Pin layout xml screenshot

在安卓上很好用,但我也想在iOS应用中使用这个xml布局。我想知道是否有一种方法可以将这个xml布局转换为svg或png格式,或者任何允许我重复使用它而无需重新创建的格式。它需要具有透明度,如果可能的话,.svg比.png更好。如果可以的话,我希望只有显示的可见部分可以点击。
1个回答

4
iOS中相应的技术是苹果的"autolayout"系统。一旦掌握了使用方法,它就非常容易使用。然而,像任何专业技术一样,需要专业知识。当然,你可以只制作一个透明PNG图片,并将其用作UIButton按钮的图像。我强烈建议在苹果中使用"UIButton",并调整颜色等,直到获得满意的外观。但请注意,这可能与其他平台不完全相同。 两个关键点是:从技术上讲,几乎不可能使应用程序在不同平台上看起来完全相同;除了在游戏中,几乎所有人都认为应该避免尝试这样做。对于按钮等元素,应允许其在每个平台/操作系统版本上自然运行。顺便说一句,我不知道为什么会有人对你的问题进行反对投票。跨平台问题是当今开发中最关键的问题之一。

我认为它被降权的原因是问题的答案是“不”,而且可以通过快速的谷歌搜索找到。(我没有投票降权) - nukeforum
答案怎么可能是完全“没有”呢?我想至少我可以裁剪我拍摄的屏幕截图,在Photoshop中进行编辑,并将其用作UIButton的图像。我只是想知道是否有更好的方法,因为我在网上找不到更好的东西。 - Pat Myron
1
阅读答案的第三句话,它解释了如何像您所说的那样使用PNG ->“UIButton”。 - Fattie

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接