构建Android UI的简单方法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/851882/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:27:43  来源:igfitidea点击:

Easy way to build Android UI?

androiduser-interface

提问by hkhalifa

Is there a tool or a website that could help me create a UI for an Android application using drag-and-drop?

是否有工具或网站可以帮助我使用拖放操作为 Android 应用程序创建 UI?

I found this sitebut want to know if there is a more stable tool or website for this?

我找到了这个网站,但想知道是否有更稳定的工具或网站?

回答by Todd Grigsby

Allow me to be the one to slap a little reality onto this topic. There is no good GUI tool for working with Android. If you're coming from a native application GUI environment like, say, Delphi, you're going to be sadly disappointed in the user experience with the ADK editor and DroidDraw. I've tried several times to work with DroidDraw in a productive way, and I always go back to rolling the XML by hand.

请允许我成为这个话题的一个小现实。没有用于 Android 的良好 GUI 工具。如果您来自原生应用程序 GUI 环境,例如 Delphi,那么您会对 ADK 编辑器和 DroidDraw 的用户体验感到失望。我曾多次尝试以高效的方式使用 DroidDraw,而且我总是回到手动滚动 XML。

The ADK is a good starting point, but it's not easy to use. Positioning components within layouts is a nightmare. DroidDraw looks like it would be fantastic, but I can't even open existing, functional XML layouts with it. It somehow loses half of the layout and can't pull in the images that I've specified for buttons, backgrounds, etc.

ADK 是一个很好的起点,但它并不容易使用。在布局中定位组件是一场噩梦。DroidDraw 看起来很棒,但我什至无法用它打开现有的功能性 XML 布局。它以某种方式丢失了一半的布局,并且无法提取我为按钮、背景等指定的图像。

The stark reality is that the Android developer space is in sore need of a flexible, easy-to-use, robust GUI development tool similar to those used for .NET and Delphi development.

严峻的现实是,Android 开发人员空间急需一种灵活、易于使用、健壮的 GUI 开发工具,类似于用于 .NET 和 Delphi 开发的工具。

回答by Josef Pfleger

The Android Development Tools (ADT) plugin for Eclipse includes a visual editor for android application layout files:

Eclipse 的 Android 开发工具 (ADT) 插件包括一个用于 android 应用程序布局文件的可视化编辑器:

http://developer.android.com/tools/help/adt.html

http://developer.android.com/tools/help/adt.html

回答by NickA

The easiest way is with REBOL 3:

最简单的方法是使用 REBOL 3:

http://rebolforum.com/index.cgi?f=printtopic&permalink=Nick25-Aug-2013/10:08:38-7:00&archiveflag=new

http://rebolforum.com/index.cgi?f=printtopic&permalink=Nick25-Aug-2013/10:08:38-7:00&archiveflag=new

Here are 10 fully functional demo programs, with GUIs. These run on Android anddesktop OSs, using the exact same code:

这里有 10 个功能齐全的演示程序,带有 GUI。这些在 Android桌面操作系统上运行,使用完全相同的代码:

REBOL []
load-gui
view [text "Hello World!"]


REBOL [title: "Tiny Note Editor"]
do %r3-gui.r3  ; download this file manually or just use load-gui as above
view [
    a1: area
    button "Save" on-action [write %notes.txt get-face a1]
    button "Load" on-action [set-face a1 to-string read %notes.txt]
]


REBOL [title: "Data Entry to CSV File"]
do %r3-gui.r3
view [
    text "First Name:"
    f1: field
    text "Last Name:"
    f2: field
    button "Submit" on-action [
        write/append %cntcts.txt rejoin [
            mold get-face f1 " " mold get-face f2 newline
        ]
        request "" "Saved"
    ]
    a1: area
    button "Load" on-action [set-face a1 to-string read %cntcts.txt]
]


REBOL [title: "Text File Reader (How to use a text list file selector)"]
do %r3-gui.r3
view [
    a1: area
    button "Load" on-action [
        files: read %./
        view/modal [
            text "File Name:"
            t2: text-list files on-action [
                set-face a1 to-string read(to-file pick files get-face t2)
                unview
            ]
        ]
    ]
]


REBOL [title: "List-View (Grid) Example"]
do %r3-gui.r3
view [
    text-table ["1" 200 "2" 100 "3"][
        ["asdf" "a" "4"]
        ["sdfg" "b" "3"]
        ["dfgh" "c" "2"]
        ["fghj" "d" "1"]
    ] 
]


REBOL [title: "Calculator"]
do %r3-gui.r3
stylize [
    btn: button [
        facets: [init-size: 50x50]
        actors: [on-action:[set-face f join get-face f get-face face]]
    ]
]
view [
    hgroup [
        f: field return
        btn "1"  btn "2"  btn "3"  btn " + "  return
        btn "4"  btn "5"  btn "6"  btn " - "  return
        btn "7"  btn "8"  btn "9"  btn " * "  return
        btn "0"  btn "."  btn " / "   btn "=" on-action [
            attempt [set-face f form do get-face f]
        ]
    ]
]


REBOL [title: "Sliding Tile Puzzle"]
do %r3-gui.r3
stylize [
    p: button [
        facets: [init-size: 60x60  max-size: 60x60]
        actors: [
            on-action: [
                t: face/gob/offset
                face/gob/offset: x/gob/offset
                x/gob/offset: t
            ]
        ]
    ]
]
view/options [
    hgroup [ 
        p "8"   p "7"   p "6"   return
        p "5"   p "4"   p "3"   return
        p "2"   p "1"   x: box 60x60 white
    ]
] [bg-color: white]


REBOL [title: "Math Test"]
do %r3-gui.r3
random/seed now
x: does [rejoin [random 10 " + " random 20]]
view [
    f1: field (x)
    text "Answer:"
    f2: field on-action [
        either (get-face f2) = (form do get-face f1) [
            request "Yes!" "Yes!"][request "No!" "No!"
        ]
        set-face f1 x
        set-face f2 ""
        focus f2
    ]
]


REBOL [title: "Minimal Cash Register"]
do %r3-gui.r3
stylize [fld: field [init-size: 80]]   
view [
    hgroup [
        text "Cashier:"   cashier: fld 
        text "Item:"      item: fld 
        text "Price:"     price: fld on-action [
            if error? try [to-money get-face price] [
                request "Error" "Price error" 
                return none
            ]
            set-face a rejoin [
                get-face a mold get-face item tab get-face price newline
            ]
            set-face item copy "" set-face price copy ""
            sum: 0
            foreach [item price] load get-face a [
                sum: sum + to-money price
            ]
            set-face subtotal form sum
            set-face tax form sum * .06
            set-face total form sum * 1.06 
            focus item
        ]
        return
        a: area 600x300
        return
        text "Subtotal:"   subtotal: fld 
        text "Tax:"        tax: fld 
        text "Total:"      total: fld
        button "Save" on-action [
            items: replace/all (mold load get-face a) newline " "
            write/append %sales.txt rejoin [
                items newline get-face cashier newline now/date newline
            ]
            set-face item copy "" set-face price copy "" 
            set-face a copy ""    set-face subtotal copy ""
            set-face tax copy "" set-face total copy ""
        ]
    ]
]


REBOL [title: "Requestors"]
do %r3-gui.r3
x: request/ask "Question" "Do you like this?."
either x = false [print "No!"] [print "Yes!"]
x: request/custom "" "Do you like this?" ["Yay" "Boo"]
either x = false [print "Boo!"] [print "Yay!"]
view [button "Click me" on-action[request "Ok" "You clicked the button."]]

回答by rlc

DroidDrawseems to be very useful. It has a clean and easy interface and it is a freeware. Available for Windows, Linux and Mac OS X. I advice a donation.

DroidDraw似乎非常有用。它有一个干净和简单的界面,它是一个免费软件。适用于 Windows、Linux 和 Mac OS X。我建议捐赠。

If you don't like it, you should take a look at this site. There are some other options and other useful tools.

如果你不喜欢它,你应该看看这个网站。还有一些其他选项和其他有用的工具。

回答by Simon

You can also try this. If you like the model view controller concept and fast prototyping then I would say you will like the idea behind it;)

你也可以试试这个。如果你喜欢模型视图控制器的概念和快速原型设计,那么我会说你会喜欢它背后的想法;)

SimpleUi ( https://github.com/bitstars/SimpleUi )

SimpleUi ( https://github.com/bitstars/SimpleUi )

The generated UI (code below):

生成的用户界面(下面的代码):

enter image description here

在此处输入图片说明

The complete code to create this Android UI:

创建此 Android UI 的完整代码

enter image description here

在此处输入图片说明

I use it in real applications, not only for fast prototyping or dialogs and its well tested over the years. The concept is based on the model view control principle and for most common scenarios there are ready to use components which automatically look correct on any device. I don't say it should be used for any UI (e.g. listviews should be done by hand) but for most usecases this should be quite handy ;) Oh and feel free to fork it and improve it further if you want

我在实际应用程序中使用它,不仅用于快速原型设计或对话框,而且多年来经过了良好的测试。该概念基于模型视图控制原则,对于大多数常见场景,都有现成的组件,可以在任何设备上自动看起来正确。我不是说它应该用于任何 UI(例如,列表视图应该手动完成)但对于大多数用例来说这应该非常方便;) 哦,如果你愿意,可以随意分叉并进一步改进它

回答by lostInTransit

Droiddraw is good. I have been using it since long and haven't faced any issues yet (though it crashes sometimes, but thats ok)

Droiddraw 很好。我已经使用它很久了,还没有遇到任何问题(虽然它有时会崩溃,但没关系)

回答by user1612540

https://play.google.com/store/apps/details?id=com.mycompany.easyGUItry this tool its not for free but offers simple way to create android ui on your phone

https://play.google.com/store/apps/details?id=com.mycompany.easyGUI试试这个工具,它不是免费的,但提供了在手机上创建 android ui 的简单方法

回答by Paul A.

This looks like a more promising solution: IntelliJ Android UI Designer.

这看起来像是一个更有前途的解决方案:IntelliJ Android UI Designer。

http://blogs.jetbrains.com/idea/2012/06/android-ui-designer-coming-in-intellij-idea-12/

http://blogs.jetbrains.com/idea/2012/06/android-ui-designer-coming-in-intellij-idea-12/

回答by Nostradamus

This is an old question, that unfortunately even several years on doesn't have a good solution. I've just ported an app from iOS (Obj C) to Android. The biggest problem was not the back end code (for many/most folks, if you can code in Obj C you can code in Java) but porting the native interfaces. What Todd said above, UI layout is still a complete pain. In my experience, the fastest wat to develop a reliable UI that supports multiple formats etc is in good 'ol HTML.

这是一个古老的问题,不幸的是,即使几年过去也没有好的解决方案。我刚刚将一个应用程序从 iOS (Obj C) 移植到 Android。最大的问题不是后端代码(对于许多/大多数人来说,如果您可以使用 Obj C 编写代码,您就可以使用 Java 编写代码)而是移植本机接口。Todd 上面说的,UI 布局仍然是一个完整的痛苦。根据我的经验,开发支持多种格式等的可靠 UI 的最快方法是使用良好的 'ol HTML。

回答by Davek804

http://www.appinventor.mit.edu/

http://www.appinventor.mit.edu/

Creating an App Inventor app begins in your browser, where you design how the app will look. Then, like fitting together puzzle pieces, you set your app's behavior. All the while, through a live connection between your computer and your phone, your app appears on your phone.

创建 App Inventor 应用程序从您的浏览器开始,您可以在其中设计应用程序的外观。然后,就像拼凑拼图一样,您可以设置应用程序的行为。一直以来,通过您的计算机和手机之间的实时连接,您的应用程序会出现在您的手机上。