Android Getting Started knowledge grooming

Source: Internet
Author: User

Manifest file: Androidmanifest.xml
    • Package: On a mobile phone, the packet name is used to identify an application. That is, you cannot have two applications with the same package name.
      • ADB uninstall package name; adb install apk full path
      • Signature, the version number is not lower than the previous version, and repeated installations overwrite
      • The new package installation failed because of a different signature.
    • Versioncode: Version number. Must be a number
    • Versionname: Version name. String. Can be Chinese
    • Apllication
      • Label: Apply the name.

      • Icon: Icons

      • Activity

        • Label
        • Icon
        • Name: The full path of the activity used. Package name +. + Class name.
Mainactivity extends Activity
    • OnCreate (): will be called when the interface is created.
      • Setcontentview () r.laytout.xx
      • Setcontentview (New TextView (this));
LinearLayout

-layout_weightsum: Can omit

    • Orientation
      • Horizontal
      • Vertical
Properties for child nodes
    • Layout_weight
    • Layout_gravity: The location of subcomponents in the interface
      • If it's a horizontal layout, you can only adjust the vertical center of gravity
      • If you have a vertical layout, you can only adjust the horizontal center of gravity. Left Right Horizontal_center
    • Layout_width: Width
      • 100px
      • Wrap_content: Package Contents
      • Match_parent: As large as the parent component
    • Layout_height: Height
TextView
- gravity: 控制内容在组件里显式的位置
Dimension value
    • dp:px=dp* (dpi/160)

      Dpi:dot per inch: The pixel count in pixels. I can adjust the resolution of my screen to show the pixel density problem.

      • Assuming the screen size is unchanged, it's two inches.
      • If the resolution is 320*480 then pixel density is 160. then 1dp = = 1px. The 160px is the center of the screen.
      • If the resolution becomes 480960. Pixel density is 240 then 1DP(240/160) = 1.5px. 160DP = = 240px. As in the center of the screen.
    • Px:

    • Pt:

    • SP: This is generally used to specify the size of the character, which functions like DP. Therefore, it is recommended to use this SP for general setting of text size.

Layout

LinearLayout

  • Orientation: Linear Layout layout direction
    • Horizontal: Horizontal Layout
    • Vertical: Vertical Layout
  • Child Node Properties:
    • Layout_gravity: The center of gravity of the component.
      • If it's a horizontal layout, it can't be centered horizontally
      • If you have a vertical layout, you cannot center vertically.
Reletivelayout:

No layout_gravity.

    • If a component is dependent on another component layout, it will be compressed if there is not enough space left.

    • If the dependent control appears later than the current control, that is, the corresponding ID cannot be found, you can

      Android:layout_above= "@+id/center"

      This method references the ID

Sub-component Common properties

Relativelayout

Properties relative to parent node

  • Android:layout_alignparentleft is left-aligned with the parent element

  • Android:layout_alignparenttop is aligned with the top of the parent element

  • Android:layout_alignparentright is right-aligned with parent element

  • Android:layout_alignparentbottom is aligned with the bottom of the parent element

  • Android:layout_centervertical Center vertically in parent element

  • Android:layout_centerhorizontal Center horizontally in parent element

  • Android:layout_centerinparent the property of the parent element centered relative to the other node

  • Android:layout_alignbaseline aligns with the specified control center (center of Gravity alignment)

  • Android:layout_alignleft left-aligned with the specified control

  • Android:layout_alignright right-aligned with the specified control

  • Android:layout_aligntop aligns with the top of the specified control

  • Android:layout_alignbottom aligns with the bottom of the specified control

  • Android:layout_torightof on the right side of the specified control

  • Android:layout_toleftof on the left side of the specified control

  • Android:layout_above the top of the specified control

  • Android:layout_below the bottom of the specified control

  • If a component is dependent on another component layout, it will be compressed if there is not enough space left.

  • If the dependent control appears later than the current control, that is, the corresponding ID cannot be found, you can

    Android:layout_above= "@+id/center"

    This method references the ID

Framelayout:
可以使用layout_gravity,而且不限制方向。
Absolutelayout:
基本没用,子组件只能设置 layout_x layout_y
Margin padding Difference

-margin is the child that sets the current component distance from the parent component border

    • padding: When setting the current component to add subcomponents, how many ranges are not available for display.
button click
setClickListener()

Logcat

    • View Display
    • The difference between sysout
    • Different grades.
    • Filter filters
      • Direct search can only search for content in text
      • Set filter through package name filtering
    • LOG.D (tag, msg)
    • LOG.V (tag, msg)
    • LOG.I (tag, msg)
    • LOG.W (tag, msg)
    • LOG.E (tag, msg)
Toast

Toast cannot be thread show on a sub-line

Toast t = Toast.makeText(MainActivity.this, "btn1被点击了", Toast.LENGTH_SHORT);t.show();

Android Getting Started knowledge grooming

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.