#####View Basic properties

1. Background background color

2. The spacing within the padding

3. Gravity

4. Id Finds a unique tag for the component

5. Visibility visible

6. Tag Finds a unique tag for the component

7. Enable specifies whether it is available, if it is “true”, or if it is “false”, the entire edit box is unavailable

8. The onClick event occurs when the object is clicked

A: I can’t think of anything clickable

They focusable

##### common listener in View:

OnClickListener OnLongClickListener Long press OnTouchListener TouchListenerCopy the code
Method 1: Define an inner class in the Activity that inherits the listener interface (in this case, OnClickListener). Common inheritance methods are as follows:  class MyListener implements View.OnClickListener{ @Override public void onClick(View v) { Toast.makeText(MainActivity.this,"you have clicked Button2",Toast.LENGTH_SHORT).show(); }} Alternatively, you can create an object for the listener, which is similar to direct inheritance. // Alternatively, create an OnClickListener object, Private view.onClickListener MyListener = new view.onClickListener () {@override public void private view.onClickListener MyListener = new view.onClickListener () {@override public void private view.onClickListener MyListener = new view.onClickListener () {@override public void onClick(View v) { Toast.makeText(MainActivity.this,"you have clicked Button2",Toast.LENGTH_SHORT).show(); }}; Both implementations call listeners the same way in the onCreate(Bundle savedInstanceState) method using the setOnClickListener() method. bt2.setOnClickListener(new MyListener());Copy the code
Method two: Implement anonymous inner classes. This approach is suitable for cases where you only want to use the listener once, and after the block runs, the listener is no longer there. bt1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this,"you have clicked Button1",Toast.LENGTH_SHORT).show(); }});Copy the code
Method three: Use the onClick property in the layout file and implement the method in the implementation file. Note that the method name should be the same as the name of the onClick property in the layout file. This method must be public // method 3, Public void onButtonClick (View View){toasts. MakeText (mainActivity. this,"you have clicked Button3",Toast.LENGTH_SHORT).show(); }}Copy the code

###TextView

1. Text Indicates the text content

2. TextColor sets the textColor

3. TextSize Sets the text font code

例 句 : It’s a textStyle

5. Drawable

5. How many lines are there

6. MaxLines Maximum number of lines

7. SingleLine mode

8.maxLength

Encountered input problems, I was speechless at that time, and I did not pay much attention to it when I used it. Now note the difference between Input size and maxLength:

If maxlength is 5, only five characters can be entered in the input box

The size attribute specifies the width of the input field. Since size is a visual design attribute, we should use CSS width instead.

EditText A component that can enter text

Hint: the

Digits: How to restrict input to the specified characters

TextColorHint: Sets the hint font color

inputType:

It could be a text box, which is what we call a text box, which is used to type in text, like a user, like an email. Article titles and stuff like that

It could be password, which is what we normally call a password field. The input of password type is filled with asterisks or black dots. No one is visible except the inputer who knows what it is.

It could be Submit, which is the usual submit button. Click, trigger the specified link directly.

It could be a button, which is a regular button. This button is just a button and has no other special purpose. Unless the JS onclick event we bind to it can do a lot of things as well.

It could be reset, which is the reset button, and we see a lot of forms, they have a retype. This resets all FORM elements in the FORM to their original values.

It can be cancel, which is the cancel button used to cancel the submission of Submit

It could be radio, which is a radio button. In a group of buttons, only one can be selected.

Can be checkbox, check button, can select more than one.

You can hide the value inside the hidden domain, which is used for passing parameters or other special purposes. Define by oneself

It can be image. With this type, the button is the image specified.

It could be “file” and this is for uploading files, we usually have pictures and things like that. The file type is used.

ImeOptions: When using android:imeOptions, be sure to set android:inputType or Android: Singleline = “true” to the EditText.

The android:imeOptions property defines eight EditTexts. ImeOptions are:

ActionDone completed corresponds to EditorInfo.IME_ACTION_DONE 2. ActionGo Forward corresponds to EditorInfo.IME_ACTION_GO 3. ActionNext corresponds to the next item Editorinfo. IME_ACTION_NEXT 4. ActionNone None Action corresponding to editorInfo. IME_ACTION_NONE 5 ActionSearch Search corresponding editorInfo. IME_ACTION_SEARCH 7. ActionUnspecified The corresponding IME_ACTION_UNSPECIFIED 8. ActionSend Sends the corresponding EditorInfo.IME_ACTION_SENDCopy the code

####EditText Related listener

AddTextChangedListener addTextChangedListener() is a TextView method. EditText inherits its methods from TextView. Before respectively, monitoring the text "change", "change", "change in" three states editText. AddTextChangedListener (new TextWatcher () {@ Override public void BeforeTextChanged (CharSequence s, int start, int count, int after) {// This method is called, indicating that in the s string, Count characters from start position will be replaced by new text of length after // Changing s in this method will cause an error. } @override public void onTextChanged(CharSequence s, int start, int before, int count) The count character from the start position has just replaced the old text of length before // Changing s in this method will cause an error. } @override public void afterTextChanged(Editable s) {// If this method is called, then somewhere in the s string has been changed. }}); 2. It is important to note, OnEditorActionListener setOnEditorActionListener this method, not when we click the EditText triggers, nor when we to edit the EditText triggered, It's triggered by hitting the Enter key on the soft keyboard after we're done editing it. EditText ET_phone = (EditText) findViewById(R.id.ET_phonenumber); T_phone.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, Int actionId, KeyEvent event) {log. e(" click ET_phone", "no response "); text.setText("Editing ET_phonenumber"); return false; }});Copy the code

####ImageView components that display images

The difference between SRC and background is that background is stretched according to the given length and width of the ImageView component, while SRC stores the size of the original image and does not stretch. SRC is the image content (foreground) and background is the background, which can be used simultaneously.

Also: scaleType only works on SRC; Bg allows you to set transparency, for example in ImageButton you can use Android :scaleType to control how images are scaled

AdjustViewBounds: When this property is true it can be used to adjust ImageView boundaries to keep the size of images in adjustViewBounds (need to be used with maxHeight or maxWidth)

ScaleType: The scaleType property is used to display images. There are eight values:

Scaletype. CENTER: The image size is the original size. If the image size is larger than the ImageView control, the middle part of the image is captured. If the image size is smaller, the image is centered

CENTER_CROP: Scale the image so that the short edge of the image is the same length as the edge of the ImageView, that is, there is no space left

CENTER_INSIDE scaletype. CENTER_INSIDE: Scale down images larger than the ImageView until the entire image is centered in the ImageView. Images smaller than the ImageView remain centered

Scaletype. FIT_CENTER: The default state of the ImageView. Large images are scaled out to center the entire image in the ImageView, and small images are scaled out to center the entire image in the ImageView

FIT_START: Scaletype. FIT_START: Scaletype. FIT_START: scaletype. FIT_START: scaletype. FIT_START: ScaleType. FIT_XY: Scales the image unequally to the size of ImageView scaleType. MATRIX: scales the image based on a 3×3 MATRIX

####ProgressBar ProgressBar, SeekBar drag bar, RatingBar scoring bar

  • Common Android progress bars are ProgressBar, SeekBar, and RatingBar. ProgressBar descends from the View class, with direct subclasses AbsSeekBar and
  • ContentLoadingProgressBar SeekBar and RatingBar is AbsSeekBar subclass, hence ProgressBar RatingBar, SeekBar parent class.
The Horizontal and Horizontal properties of progressbars include Large,Normal,Small and so on. Android: Max Sets the maximum value of the progress bar android: Progress Sets the completed progress value of the progress bar Android :progressDrawable Set the Drawable object corresponding to the ProgressBar track (mainly using the horizontal ProgressBar style from the definition) android:indeterminate Sets the progress bar shows progress inaccurate android: indeterminateDrawable set drawing does not show the progress of the progress bar Drawable object (mainly use customize ProgressBar round style) 2, SeekBar (have a slider) Android: Thumb: Specifies a Drawable object that acts as a custom slider to change the appearance of the drag bar slider. OnSeekBarChangeListener listener. (The listener determines its application scenario and allows the program to respond to changes in the position of the drag bar slider, such as the progress bar for adjusting the volume.) Android :rating Sets the default rating of the ProgressBar. Android :numStars Sets the total number of stars of the ProgressBar. Android :stepSize Set each time at least need to change how many star android: isIndicator article set up the star rating whether to allow users to change (true is not allowed to modify) OnRatingBarChangeListener listeners. (To allow the program to respond to changes in star rating)Copy the code

Related listener OnSeekBarChangedListener

OnSeekBarChangedListener: when the schedule changed to inform client callback function. These include changes triggered by the user through gestures, arrow keys, or trackballs, and programmatic changes. Public abstract void onProgressChanged (SeekBar SeekBar, int progress, Boolean fromUser{notification that progress has been changed. The fromUser parameter can be used by the client to distinguish user-triggered changes from programmatically triggered changes seekBar seekBar progress Current progress value. The value ranges from 0 to Max. Max is the value set by the user using setMax(int), Default 100 fromUser returns True if user triggered change} public abstract void onStartTrackingTouch (SeekBar SeekBar){notify user that a touch drag gesture has started. Seekbar touch seekbar} public abstract void onStopTrackingTouch (seekbar seekbar){ Notifies the user that the touch gesture has ended. Users may need to use this to enable the seekbar sliding function parameter seekbar touch seekbar}Copy the code

###ScrollView ScrollView

Android :scrollbars= “None” ScrollView constant display: Android :fadeScrollbars= “false” Set vertical scrollbars drawable (e.g. color) : Android: scrollbarThumbVertical, if used in the ScrollView android: scrollbarThumbHorizontal, have no effect. Set the scrollbarSize: android:scrollbarSize= “20dp” in ScrollView, represents the width

######ScrollView and HorizontalScrollView: FAQ:

The compiler will tell us: “A Scroll view can have only one child”. In the HorizontalScrollView, only one direct child View can exist. So the correct use is to use a control like LinearLayout to put multiple sub-views into it

###### and your mutual encouragement

I want to work my way up

Fly forward on the blades at the highest point

Let the wind blow dry tears and sweat

I want to work my way up

Waiting for the sun to watch its face

Little days have big dreams

I have my day

Let the wind blow dry tears and sweat

One day I will have my day