Add DEV4.5/exo2_controle_2022

This commit is contained in:
2025-04-01 21:36:46 +02:00
parent 05f4c34fc3
commit 84bc26db6a

38
DEV4.5/exo2_controle_2022 Normal file
View File

@@ -0,0 +1,38 @@
Fichier CustomView.java
package com.example.organisation;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
public class CustomView extends View {
private Paint paint;
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
paint = new Paint();
paint.setColor(0xFFFFBB33); // Couleur (255, 187, 51)
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
}
}
Modification de activity_main.xml
(Remplacez les View par CustomView)
<com.example.organisation.CustomView
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="2"/>
<com.example.organisation.CustomView
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"/>