Книга: Beginning Android
Settings, Preferences, and Options (Oh, My!)
Settings, Preferences, and Options (Oh, My!)
With your favorite desktop Web browser, you have some sort of “settings” or “preferences” or “options” window. Between that and the toolbar controls, you can tweak and twiddle the behavior of your browser, from preferred fonts to the behavior of Javascript.
Similarly, you can adjust the settings of your WebView
widget as you see fit, via the WebSettings
instance returned from calling the widget’s getSettings()
method.
There are lots of options on WebSettings
to play with. Most appear fairly esoteric (e.g., setFantasyFontFamily()
). However, here are some that you may find more useful:
• Control the font sizing via setDefaultFontSize()
(to use a point size) or setTextSize()
(to use constants indicating relative sizes like LARGER
and SMALLEST
)
• Control Javascript
via setJavaScriptEnabled()
(to disable it outright) and setJavaScriptCanOpenWindowsAutomatically()
(to merely stop it from opening pop-up windows)
• Control Web site rendering via setUserAgent()
— 0 means the WebView
gives the Web site a user-agent string that indicates it is a mobile browser, while 1 results in a user-agent string that suggests it is a desktop browser
The settings you change are not persistent, so you should store them somewhere (such as via the Android preferences engine) if you are allowing your users to determine the settings, versus hard-wiring the settings in your application.
- Разработка приложений баз данных InterBase на Borland Delphi
- Open Source Insight and Discussion
- Introduction to Microprocessors and Microcontrollers
- Chapter 6. Traversing of tables and chains
- Chapter 8. Saving and restoring large rule-sets
- Chapter 11. Iptables targets and jumps
- Chapter 5 Installing and Configuring VirtualCenter 2.0
- Chapter 16. Commercial products based on Linux, iptables and netfilter
- Appendix A. Detailed explanations of special commands
- Appendix B. Common problems and questions
- Appendix D. TCP options
- Appendix E. Other resources and links