Android Knowledge (i)

Source: Internet
Author: User

Record the fragmented knowledge points used in the project for the purpose of memo.

  • Activity start state android:screenOrientation:portrait limit horizontal screen
    • Singletop is performed only once and is usually used on the Welcome page
    • The activity on the Singletask stack is destroyed, usually for the first activity
  • MAIN && Launche
    • Android.intent.action.MAIN decide which activity to start first
    • Android.intent.category.LAUNCHER decide which is displayed in the program list
    • If you have two activity with main and launcher, two app icons appear on Android
  • Randroid:onclick= "ClickHandler" Directly binds a button click event in Layout
  • View has gone, visible, invisible three states, of which gone and invisible are not visible, but the former more accurate is hidden (not occupying the position also invisible), the latter is invisible (occupy position, invisible)
  • Timer.schedule (task,1000, 1000); Delay 1000ms after execution, 1000ms execution once
  • Overridependingtransition: The animation used to switch from one activity to another activity, which has two parameters, one parameter is the animation of the first activity entry, The other parameter is the animation when the second activity exits
  • Activity.this.finish (): When your activity is done, or when the activity needs to be closed, Call this method. When you call this method, the system simply moves the top activity out of the stack, and does not call the Ondestory () method in a timely manner, and its resource usage is not released in time. Because the stack is removed, you won't find the activity when you click on the "Back" button on your phone. Ondestory () is a system that destroys the space occupied by the instance of the activity in memory.

  • ImageView Src is the foreground, background is the background, the background will be stretched according to the size of the control, SRC is the original image; ScaleType only works on SRC
    • Android:scaletype= "Center" is displayed in the center. does not scale. No cuts
    • Android:scaletype= "centerinside" picture width (high) is greater than imageview width (high), proportionally reduce the picture, so that the picture width (high) is less than or equal to ImageView width (high). Center display.
  • Gravity && layout_gravity be good at using include to get rid of duplicate code in layout, such as Public tab page, Progress prompt box, etc.
    • Android:gravity is the position of the contents of the view relative to the view, such as setting the button inside the text relative to the left and middle position of the view;
    • Android:layout_gravity is used to set the position of the view relative to the parent view, such as setting the relative position of the button in layout: The screen is centered, horizontally centered, and so on.
      Common example: android:gravity= "center_vertical" vertical center;

  • Activity and other custom classes (such as tasks, view, and so on) interact:
    • Define an interface
    • Activity inherits and implements these interfaces
    • When the task is started, the activity is injected into the business class in the constructor, similar to the Onattach
    • Callback the response interface in a custom task

Android Knowledge (i)

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.