Introduction to OPhone excellent reading software development experience (1)

Source: Internet
Author: User

Reading page
First, start with the layout. The reading interface adopts the RelativeLayout Layout mode. The purpose is to keep a menu key under the screen for easy touch operations.

 


Next we will gradually explain the code for some page la s on the screen:

 
  1. <?xml version="1.0" encoding="utf-8"?>     
  2. <RelativeLayout xmlns:android=  
  3. "http://schemas.android.com/apk/res/android"    
  4. androidrientation="vertical"    
  5. android:layout_width="fill_parent"    
  6. android:layout_height="fill_parent"    
  7. android:background="#FFdbdbdb"    
  8. >     

Set full screen and background color

 
  1. <WebView android:id="@+id/webkit"      
  2. android:layout_width="fill_parent"      
  3. android:layout_height="fill_parent"      
  4. android:background="#FFdbdbdb"    
  5. />   

The full-screen WebView control, that is, the browser control, also sets the background color.

 
  1. <Button android: layout_width = "wrap_content"
  2. Android: id = "@ + id/Button01"
  3. Android: layout_centerHorizontal = "true"
  4. Android: layout_centerInParent = "true"
  5. Android: layout_alignParentRight = "false"
  6. Android: layout_alignWithParentIfMissing = "true"
  7. Android: layout_height = "wrap_content"
  8. Android: layout_alignBottom = "@ layout/main" android: text = "menu">
  9. </Button>

The menu key settings, layout_centerHorizontal layout_alignParentRight button settings ensure that the menu key remains in the middle. android: layout_alignBottom = "@ layout/main" sets the menu key at the bottom of the page.

 
  1. <Button android: layout_width = "wrap_content"
  2. Android: id = "@ + id/ButtonUp"
  3. Android: layout_centerHorizontal = "true"
  4. Android: layout_centerInParent = "false"
  5. Android: layout_alignParentLeft = "true"
  6. Android: layout_alignWithParentIfMissing = "true"
  7. Android: layout_height = "wrap_content"
  8. Android: layout_alignBottom = "@ layout/main" android: text = "Previous Page">
  9. </Button>
  10. <Button android: layout_width = "wrap_content"
  11. Android: id = "@ + id/ButtonDown"
  12. Android: layout_centerHorizontal = "true"
  13. Android: layout_centerInParent = "false"
  14. Android: layout_alignParentRight = "true"
  15. Android: layout_alignWithParentIfMissing = "true"
  16. Android: layout_height = "wrap_content"
  17. Android: layout_alignBottom = "@ layout/main" android: text = "next page">
  18. </Button>
  19. </RelativeLayout>

Similarly, the buttons on the top and bottom pages are set on one left and one right.

Now you have prepared the page.

The advantage of RelativeLayout layout is that you can place the button you need on the relative position of the screen. It is suitable for mobile phones of different screen sizes to adopt unified code operations, reducing the burden of transplantation. The layout is only at the front and bottom of the screen, and can also be at the center and top of the screen.

Basic use of webView controls
The browser control is webView. The following describes how to set and monitor the webView control: webView is not available in j2s, which is similar to Symbian and. net CF provides a function-like browser control, which can be used to directly access the webpage or display the input HTML string. The function is powerful, similar to that of Symbian or. net CF browser controls have the following advantages:
 
1. Powerful functions: supports CSS, Java script, and other HTML languages, so that the page can be more beautiful.
2. the browser controls can be set in great detail, such as the font size, background color, and scroll bar style.
3. Capture all browser operations, such as clicking a URL to open or close a URL
4. Well integrated layout.
5. Even webView can interact with JS.

  • Loading and using SDCard in OPhone Simulator
  • How to get started with Ophone Widget SDK
  • Quick Start: getting started with Ophone and Android
  • How to port a j2-api to OPhone
  • Combat between Android platform and OPhone

After using the webView layout page, we first get the webView instance, and browser is the webView object:

Browser = (WebView) findViewById (R. id. webkit );

After obtaining the instance, we define WebSettings for browser. WebSettings is the specific setting class of WebView, which can be very detailed.

WebSettings bs = browser. getSettings ();
The webView setting object is obtained. Set the browser control


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.