Android Development Notes (1) -- View, androidview

Source: Internet
Author: User

Android Development Notes (1) -- View, androidview
I,ViewBasic knowledge IDE -- Integrated Development EnvironmentIntegrated development environment, comprehensive editing environment with multiple featuresXML -- Extensible Markup LanguageExtensible Markup Language, used to describe the Android appearance and build a layout.

View --Rectangular area used to display content on the screenHere we will introduce three types of views, including the Image View, TextView, And Button. The Layout screen is composed of all views ).

 

The application is displayed and interacted with the user interface (User Interface)

Although the content display varies, it is placed in a rectangle structure. As long as the background color is set to transparent and the same color, it can be invisible, but it can still be forcibly drawn.

 

II, TextView

 

1 Enable and disable tags Auto-closing label
<TextView android: xxxx = "xxx" /> Disable tags separately <TextView android: xxxx = "xxx"
<TextView/>
  2 , Description View Behavior or appearance characteristics -- Attribute

TextView includes text, textColor, background, layout_width, and layout_height. All attributes have default values. If no additional settings are set, the default values are displayed. Attribute values (right of the equation) need to be placed Double quotation marks.

View AndroidDeveloper: TextView Get more attributes

  3 Attribute explanation ( 1 ) Length and width Layout_width , Layout_heightUnit Dp_density-independentpixels, Display the same size regardless of the device resolution. When pixel is used, the same size is set to show different sizes on different cell phone resolution screens, especially on ultra-high resolution screens. Accessible targets ( Button ) At least 48dp Width.

Fixed length and width:Regardless of the internal text, the length and width of the View are fixed, and it is not suitable for changing the content. Wrap_content ):If you need View to automatically fit the text, you only need to properly set android: padding = "20dp" to display it perfectly as the text changes.
Parent element length and width: Match_parent Forcibly extend the view to the parent element size 

 

 

 

( 2 ) Text display Use TextSize Modify the size of the displayed textTo SpUnit -- Scale independent pixelsProportional irrelevant pixels, the same as dp; sp is only applicable to fonts, because it is adjusted based on users' preferences and settings on the font size. Direct use AndroidTextAppearanceSet Font Size -- Small/Medium/Large: 14/18/22sp by default  TextColor Modify the color of the displayed text
Deep gray is used in the example -- @ Android: color/darker_greyCan also be changed @ Android: color/black, @ Android: color/whiteBut Android provides a small number of colors. .Use Exact hexadecimal color codeTo reference any Color, view the Color section of Materials Design, all colors are given to specific code. ③ Other text display
All letters? All Case sensitivityThe default value is False.
Change bold and italic, Multiple options with "|"
III, ImageView

Android: src = "@ drawable/cake" --Indicates that the image named cake is referenced, and the suffix @ is not required. Android app Reference a resource, Drawable Resource Type In Android Studio needs to manually add images to the application drawable folder.

Android: scaledType = "center"The image size will not be changed, but will only be displayed in the center Android: scaledType = "centerCrop"Scale down the Image Based on the length and width limit and retain the aspect ratio. The width and height of the image are at the same time greater than or equal to ImageView. Android: scaledType = "centerInside"Center display, ensure that the image width and height are smaller than or equal to ImageView, scaled proportionally. Android: scaledType = "fitCenter"Center display, zoom in or out proportionally until one direction is completely determined. If the image height is smaller than the View height, the image is reduced. Statement:1, this note for text and pictures are personal original, please do not reprint 2, Android development courses in 2017 4 years to participate in Google developer learning, notes original http://www.studyjamscn.com/thread-18914-1-1.html

 

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.