I want to know the answer of these following questions. These questions are based on Custom view.
Q1. I have read onAttachedToWindow documentation from android docs. What is meaning of this line
however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).
According to me, Meaning of bold text line is : onAttachedToWindow can be call after or before the onMeasure method. If I am not wrong then, in which case onAttachedToWindow will call after onMeasure ?
Q2. What is usecase of onAttachedToWindow?
Q3. Why onMeasure called twice for below code?
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:custom="http://ift.tt/1AhUluK"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.example.mycustomview.customview
android:layout_width="wrap_content"
android:layout_height="wrap_content"
custom:textColor="#ffffff"
custom:textSize="10sp" />
</LinearLayout
In this, I am using Linear layout. Why customview called twice?
Q4. why onMeasure also called after onSizeChanged method?
Q5. Why height, width calculated by onSizeChanged() is not same with height, width calculated by onMeasure?
Aucun commentaire:
Enregistrer un commentaire