What is the difference between a View and widget in Android?

后端 未结 9 1821
轮回少年
轮回少年 2020-12-24 11:39

What is the difference between a View and widget in Android?

9条回答
  •  渐次进展
    2020-12-24 12:19

    I don't believe any of the earlier answers are really correct. Different UI toolkits use different terminology for what is often essentially the same thing, and it is true that an Android View is pretty similar to a .NET Control or a Qt widget.

    But "widget" also means something very specific in Android. If you long press on the home screen, you get an "Add to home screen" dialog that offers to add Widgets (among other things). If you touch the Widgets line, you get a menu of widgets like Analog Clock 1 through 4.

    According to developer.android.com/guide/topics/appwidgets, these are special entities that lets your process display content in another process's View. Like the home screen. There is a special broadcast protocol that you inherit for free, but you also interact with the Views in your developer.android.com/reference/android/widget/RemoteViews.html host via a special protocol that appears to involve marshaling. I have just started to look into writing one (which is how I found this question) but the docs do say that you can only use FrameLayout, LinearLayout, and RelativeLayout layouts, and that they can only contain AnalogClock, Button, Chronometer, ImageButton, ImageView, ProgressBar',TextView, andViewFlipper` "widget classes" - "Descendants of these classes are not supported."

    This is just a bit restrictive!

提交回复
热议问题