Android View Details

Source: Internet
Author: User

I. Structure
Java. lang. Object
Android. view. View

Known direct subclass:
AnalogClock, ImageView, KeyboardView, ProgressBar, SurfaceView, TextView, ViewGroup, ViewStub
Known indirect subclass:
AbsListView, AbsSeekBar, AbsSpinner, vertex, AdapterView <T extends Adapter>, AppWidgetHostView, cursor, Button, CheckBox, CheckedTextView, Chronometer, distance, DatePicker, DialerFilter, DigitalClock, EditText, distance, extractEditText, Gallery, GLSurfaceView, Gallery, Gallery, GridView, layout, ImageButton, ImageSwitcher, LinearLayout, ListView, MediaController, metrics, metrics, groups, RadioGroup, RatingBar, metrics, ScrollView, SeekBar, slidingDrawer, Spinner, TabHost, TabWidget, cursor, TableRow, TextSwitcher, TimePicker, ToggleButton, cursor, VideoView, ViewAnimator, ViewFlipper, ViewSwitcher, WebView, cursor, ZoomControls

Ii. xml attributes
Attribute name
Description
Android: background
Set the background color/background image. You can set the background to transparent in either of the following ways: "@ android: color/transparent" and "@ null ". Note that TextView is transparent by default. You do not need to write this attribute, but you have to write this attribute if you want to make it transparent.
Android: clickable
Whether to respond to click events.
Android: contentDescription
Set the description of View remarks, which is provided as an auxiliary function and provides descriptions for views without text descriptions, such as ImageButton. There is no effect on the interface. You can control it in the program and temporarily put a little string of data.
Android: drawingCacheQuality
Sets the translucent quality when drawing. You can set the following values: auto (default, determined by the Framework)/high (high quality, high color depth, more memory consumption/low (low quality, uses a lower color depth, but uses less memory ).
Android: duplicateParentState
If this attribute is set, the drawing status (cursor, press, etc.) is obtained directly from the parent container ). See the code section below. Note that the current test is only to get the drawing status, but not to get the event. That is, when you click LinearLayout, the Button has the effect of being clicked, but does not execute the click event.
Android: fadingEdge
Set the orientation of the border gradient when you pull the scroll bar. None (border color unchanged), horizontal (horizontal color fades), vertical (vertical color fades ). Refer to
Android: fadingEdgeLength
Set the length of the border gradient.
Android: fitsSystemWindows
Whether to consider the system window (such as the status bar) when setting Layout Adjustment)
Android: focusable
Set whether to obtain the focus. If requestFocus () is called, the latter takes priority. Note: If you want to set a focal point for an EditText file in the form, you cannot set the light to false. You must set the focusable In Front Of The EditText file to false. To obtain the focus in Touch mode, you must set focusableInTouchMode to true.
Android: focusableInTouchMode
Set whether the View can get the focus in Touch mode.
Android: hapticFeedbackEnabled
Set touch feedback. (Note: If you do not know how to use it when you press the soft key or perform some UI interaction, you can find the keyword performHapticFeedback or HapticFeedback .)
Android: id
Set a unique ID for the current View in layout. xml. You can find the corresponding View by calling View. findViewById () or Activity. findViewById. Different layout. xml definitions of the same id do not conflict. Format: @ + id/btnName"
Android: isScrollContainer
Set the current View as a rolling container. The result is not tested here. You do not need to set this attribute at all for ListView/GridView/ScrollView, and for EdidText, android: scrollbars can also get a scroll bar.
Android: keepScreenOn
Whether the View remains awake when it is visible. This attribute is often used in LinearLayout, but it does not work in the simulator.

Android: longClickable
Set whether to respond to the long press event.
Android: minHeight
Set the minimum view height
Android: minWidth
Sets the minimum width of a view.
Android: nextFocusDown
Set the following view to get the next focus. Focus movement is based on an algorithm for finding nearest neighbor in a given direction. If the specified view does not exist, a running error is reported when you move the focus. You can set imeOptions = actionDone so that the input will jump to the next focus.
Android: nextFocusLeft
Set the specified view on the left to get the next focus.
Android: nextFocusRight
Set the specified view on the right to get the next focus.
Android: nextFocusUp
Set the top view to get the next focus.
Android: onClick
The specified method is called from the context when you click. Specify a method name. Generally, the Activity defines a function that complies with the following parameters and return values, and specifies the method name string as the value:
Public void onClickButton (View view)
Android: onClick = "onClickButton"
Android: padding
Set the margin between top, bottom, and left to fill the white space in pixels.
 
Android: paddingBottom
Set the padding at the bottom to fill the white space in pixels.

Android: paddingLeft
Set the left margin to fill the white space in pixels.

Android: paddingRight
Set the margin on the right to fill the white space in pixels.

Android: paddingTop
Set the margin above to fill the white space in pixels.

Android: saveEnabled
Set whether to save the View data when the window is frozen (such as rotating the screen). The default value is true, but only when you need to set the id for automatic saving, see here.
Android: scrollX
Set the offset value for horizontal scrolling in pixels. This effect can be seen in the GridView.
Android: scrollY
Sets the offset value for vertical scrolling in pixels.
Android: scrollbarAlwaysDraw
HorizontalTrack
Sets whether the vertical scroll bar is always displayed. ScrollView and ListView test are ineffective here.
Android: scrollbarAlwaysDraw
VerticalTrack
Sets whether the vertical scroll bar is always displayed. ScrollView and ListView test are ineffective here.
Android: scrollbarDefault
DelayBeforeFade
Starts to fade after setting N milliseconds, in milliseconds.
Android: scrollbarFadeDuration
Set the time for the scroll bar to fade out (from the beginning to the end), in milliseconds. In Android2.2, the scroll bar disappears after being rolled, and then appears again. It is displayed in versions 1.5 and 1.6.
Android: scrollbarSize
Set the width of the scroll bar.
Android: scrollbarStyle
Set the style and position of the scroll bar. Set values: insideOverlay, insideInset, outsideOverlay, and outsideInset. There are not too many results. The following is a comparison between outsideOverlay and outsideInset:
 
 
Android: scrollpolicumbhorizontal
Set the drawable of the horizontal scroll bar.

Android: scrollpolicumbvertical
Set the drawable of the vertical scroll bar.

Android: scrollbarTrackHorizontal
Set the color drawable of the horizontal scroll bar background (track)

Android: scrollbarTrackVertical
Set the drawable of the vertical scroll bar background (track ).
Setting the color value, such as "android: color/white", will produce an ugly result,
I don't even understand this attribute. Here we can
See res/drawable/In ApiDemos/
Scrollbar_vertical_thumb.xml and
Scrollbar_vertical_track.xml. Set the code:
Android: scrollbarTrackVertical
= "@ Drawable/scrollbar_vertical_track"

Android: scrollbars
Set the display of the scroll bar. None (hidden), horizontal (horizontal), vertical (vertical ). See the following code to demonstrate how to use this attribute to enable a scroll bar in EditText. However, other containers, such as LinearLayout, are set but have no effect.

Android: soundEffectsEnabled
Set whether there is sound effect when you click or touch
Android: tag
Set a text tag. You can use View. getTag () or for
View. findViewWithTag () retrieves the View containing the tag string. However
Generally, it is better to query the View by ID because it is faster and allows
Check the type during compilation.
Android: visibility
Set whether to display the View. Setting Value: visible (default value, display), invisible (not displayed, but still occupies space), gone
(Not displayed, not occupying space)
 
Iv. Code
4.1 android: duplicateParentState
<LinearLayout android: clickable = "true" android: background = "# ff0fff" android: layout_width = "100dp" android: layout_height = "100dp">
<Button android: duplicateParentState = "true" android: layout_width = "wrap_content" android: layout_height = "wrap_content"/>
</LinearLayout>
4.2 android: scrollbars
<EditText android: layout_width = "fill_parent"
Android: layout_height = "wrap_content" android: minHeight = "50dp"
Android: background = "@ android: drawable/editbox_background"
Android: scrollbars = "vertical"
Android: maxLines = "4">
</EditText>
 
V. Legacy issues
5.1 The following attributes have been reviewed and tried for many times, but they have no effect. They can only be put on hold for the time being. You will also be welcomed to provide comments and clues to share your experiences:
Android: scrollbarAlwaysDrawHorizontalTrack
Android: scrollbarAlwaysDrawVerticalTrack
Android: isScrollContainer

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.