K
Kollen
Gast
Heyjo,
hab eine schnelle Frage und zwar wieso wird in meinem Fall die Override-Methode OnSizeChanged nicht aufgerufen wie üblicherweise in Klassen die von View erben?
EDIT: Wird aufgerufen aber nach dem Konstuktor. Nicht aufgepasst
hab eine schnelle Frage und zwar wieso wird in meinem Fall die Override-Methode OnSizeChanged nicht aufgerufen wie üblicherweise in Klassen die von View erben?
Code:
public class G**** extends LinearLayout
{
/**************************************************************************
**************************************************************** VARIABLES
*/
private LinearLayout layoutTop;
private LinearLayout layoutMid;
private LinearLayout layoutBot;
private TextView textView;
private int height;
private int width;
private int placeTopBot;
/**************************************************************************
************************************************************* CONSTRUCTORS
*/
public G****** (Context context)
{
super(context);
setWeightSum(height);
layoutTop = new LinearLayout(context);
layoutMid = new LinearLayout(context);
layoutBot = new LinearLayout(context);
addView(layoutTop);
addView(layoutMid);
addView(layoutBot);
layoutTop.setOrientation(LinearLayout.VERTICAL);
layoutMid.setOrientation(LinearLayout.VERTICAL);
layoutBot.setOrientation(LinearLayout.VERTICAL);
layoutTop.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, placeTopBot));
layoutMid.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, width));
layoutBot.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, placeTopBot));
textView = new TextView(context);
textView.setLayoutParams(new LinearLayout.LayoutParams(100, 100));
textView.setText("hallo");
textView.setTextColor(Color.BLACK);
layoutMid.addView(textView);
}
[COLOR=Red]@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(w, h, oldw, oldh);
height = h;
width = w;
placeTopBot = (height - width) / 2;
}[/COLOR]
}
Zuletzt bearbeitet von einem Moderator: