Add DEV4.5/exo2_controle_2022
This commit is contained in:
38
DEV4.5/exo2_controle_2022
Normal file
38
DEV4.5/exo2_controle_2022
Normal 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"/>
|
||||||
Reference in New Issue
Block a user