38 lines
973 B
Plaintext
38 lines
973 B
Plaintext
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"/> |