Android fragmentation knowledge concentration (2): Android knowledge concentration
1. Obtain the height of the title bar.
Rect frame = new Rect();getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);int statusBarHeight = frame.top;int contentTop = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();int titleBarHeight = contentTop - statusBarHeight;textView.setText("statusBarHeight" + statusBarHeight + ";contentTop="+ contentTop + ";titleBarHeight" + titleBarHeight);
2. Layout with Acivity
Note: This class must inherit the ActivityGroup
LocalActivityManager activityManager;activityManager = getLocalActivityManager();View view2 = activityManager.startActivity("act2",new Intent(this, Act2.class)).getDecorView();linearLayout.addView(view2, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
3. Screen and save
View view = getWindow().getDecorView();Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),view.getHeight(), Config.RGB_565); view.draw(new Canvas(bitmap)); imageView.setImageBitmap(bitmap);
4. android obtains the component size.
Use view in oncreate. getWidth () or view. getHeiht () is used to obtain the width and height of the view. It seems that there is no problem. In fact, the value they get is 0, which is not the result you want?
Why?
When the oncreate () method is called, the interface is invisible and the memory-loaded component has not been drawn. You cannot obtain its size.
So how can we get the size of the component before drawing it?
There are three methods, verified:
(1)
int width =View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED); int height =View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED); view.measure(width,height); int height=view.getMeasuredHeight(); int width=view.getMeasuredWidth();
(2)
// Add the listener ViewTreeObserver vto = view before the component is drawn. getViewTreeObserver (); vto. addOnPreDrawListener (new ViewTreeObserver. onPreDrawListener () {@ Override public booleanonPreDraw () {int height = view. getMeasuredHeight (); int width = view. getMeasuredWidth ();}});
(3)
// Added the overall layout listener ViewTreeObserver vto = view. getViewTreeObserver (); vto. addOnGlobalLayoutListener (new OnGlobalLayoutListener () {@ Override public voidonGlobalLayout () {view. getViewTreeObserver (). removeGlobalOnLayoutListener (this); int height = view. getMeasuredHeight (); int width = view. getMeasuredWidth ();}});
Then, when the activity enters the runtime, the component size acquisition method is very simple. getWidth () and getHeight () are used directly ().
The android learning method has been learned in the past, and some simple layout controls have been connected, but I do not know how to learn it. I want to watch videos.
I think I should join more Android forums and ask more experts on the forums. They all have the secret. Even the students have the correct learning method.
More than two thousand years ago, Confucius said: "A person who knows is better than a person who knows better than a person who is happy ." It means to do one thing, to know it, to know it is better to love it, to love it is better to enjoy it. "Good" and "happy" means you are willing to learn and enjoy learning. This is your interest. Interest is the best teacher. If you are interested, you can have a hobby. If you are interested, you must practice it and enjoy it. If you are interested, you will have the initiative and enthusiasm for learning. So: interest is an inexhaustible source of motivation for learning. As long as you prepare for the course on weekdays to find out difficult questions, actively participate in classroom activities, carefully think about problems, and actively speak to collect incentive factors, then you will be more interested in learning, and you will be more interested in learning cultural courses.
To achieve good academic performance, you must have good study habits. The habit is the steady and persistent conditioned reflection and natural needs consolidated after repeated exercises. Establishing good study habits will make your learning feel orderly and easy. Good study habits should be: ears, eyes, brain, Mouth, hands-on, diligent exercises, multi-questioning, Diligent Thinking, re-induction, and multi-application. Pay attention to summing up regular things, in the course of learning, we need to translate the knowledge that teachers teach into our own special language and remember it permanently in our own minds. In addition, make sure that you have a certain amount of self-study time every day to broaden your knowledge and cultivate your learning ability.
1. preview the course. Pre-course preparation is an important strategy to improve the effect of lectures. Pre-course preparation is to preview the content to be taught in this course before each class. You are familiar with the course content, find the key points, difficulties, and doubts of the lectures and understanding, and write down your own puzzles and weaknesses, take the problem into the classroom, in order to solve the problem in the classroom learning.
2. classroom learning. Follow the teacher's ideas as much as possible in the classroom, and try to keep yourself in a positive listening state. Think carefully about the key points, difficulties, and doubts of the teacher, through lectures, we can solve the problems raised during previewing, deepen our understanding of the problems, and train our own thinking through lectures. Do not be satisfied with the teacher's ideas. think more about other methods or possibilities. Classroom learning is a process of two-way communication: on the one hand, the teacher tells you, and on the other hand, by giving your feedback to the teacher, the teacher knows whether the content he is talking about is understood by you. Therefore, you must think positively, answer the questions raised by the teacher, and express your opinions and opinions so that the teacher can understand your current thinking level. Take note of the lecture carefully, write down the key points, key points, and difficulties of the text, explain, prompt, and opinions of the teacher, and explain and understand your own questions. As the saying goes, "a good memory is worse than a bad pen." A sensitive head cannot resist time consumption. Note taking is a good supplementary learning method. It helps you overcome the limitations of your brain's memory and reminds you to recall the content of your classroom. However, taking notes cannot be a mechanical copy of the instructor's content. It is also a process of thinking. Make a proper choice when taking notes. The details are slightly moderate. The focus is on the key points prompted by the teacher and the difficulties you don't know. The process of taking notes must be scientifically distributed and focused on the difficulty of the subjects: For difficult subjects, 50% of the time can be heard, and 50% of the time can be taken; for subjects that focus more on flexibility and creativity, 90% of the time is enough to listen, and 10% of the time is enough to write down the outline. Note must be well-organized and clear at a glance to make notes more valuable.
3. Review after class. Review the course content in a timely manner, actively recall and re-learn as necessary to deepen the overall understanding of the course content and reduce forgetting. In addition, the process of forgetting is unbalanced. At the beginning, the process of forgetting is much faster and less forgotten in the future. According to the Law of forgetting, you can adopt appropriate review strategies to overcome forgetting. That is, you can avoid forgetting Before forgetting. Therefore, pay attention to the time schedule during the review.
According to the relevant research, the effective review schedule is:
5-10 minutes after the first review.
The second review, later or the next day.
The third review, about a week.
The fourth review, about a month.
The Fifth Review, about half a year.
Review based on the above method to effectively combat forgetting. "Live to the old, learn to be old ." People can't do without learning, life is endless, and learning is not limited. Learning refers to the process in which a person gains knowledge, experiences, and behaviors for life.
How to Develop Android programs requires knowledge
(1) first, you must have the foundation of programming, because you need to understand what programming is.
(2) Understand java, because android is a java class library, and many people start to develop android without having to write ava. This is unwise and the efficiency will be extremely low, because now android books are written at this level based on the premise that you have mastered java. If there is no java foundation, you may follow the previous chapter or two, but it will be very difficult in the future, I also had to look at android side to make up for java, and this learning of java is bound to be very bad.
(3) determine which aspect of android should be developed by yourself. If you are playing a game, you must know which type of game you are playing. For example, if you are writing a 3D game, you must have a powerful OpenGL Foundation, with strong knowledge of physical models, it is difficult for new users to understand the importance of physical models. For example, you must have played cut rope, the rope fluctuation is a very successful example.
(4) android is much easier to write than ios, and there are no strange syntaxes in ios .............
(5) However, if you want to make money on this, and the time is limited, you can directly develop apple ios and learn objective-c, because the android release market is too nonstandard, there is almost no money to develop applications, so it's okay to play it on your own.