Add DEV4.5/exo2_controle
This commit is contained in:
97
DEV4.5/exo2_controle
Normal file
97
DEV4.5/exo2_controle
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.example.q2_amyti.QuadrantView
|
||||||
|
android:id="@+id/view1"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentStart="true" />
|
||||||
|
|
||||||
|
<com.example.q2_amyti.QuadrantView
|
||||||
|
android:id="@+id/view2"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentEnd="true" />
|
||||||
|
|
||||||
|
<com.example.q2_amyti.QuadrantView
|
||||||
|
android:id="@+id/view3"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentStart="true" />
|
||||||
|
|
||||||
|
<com.example.q2_amyti.QuadrantView
|
||||||
|
android:id="@+id/view4"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentEnd="true" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
|
package com.example.q2_amyti;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class QuadrantView extends View {
|
||||||
|
|
||||||
|
private Paint paintFill;
|
||||||
|
private Paint paintBorder;
|
||||||
|
|
||||||
|
public QuadrantView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
paintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
paintFill.setColor(0xFFAACCEE); // Couleur de fond
|
||||||
|
|
||||||
|
paintBorder = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
paintBorder.setColor(0xFF000000); // Bordure noire
|
||||||
|
paintBorder.setStyle(Paint.Style.STROKE);
|
||||||
|
paintBorder.setStrokeWidth(4); // Épaisseur de la bordure
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
|
||||||
|
float radius = 20f; // coins arrondis
|
||||||
|
RectF rect = new RectF(0, 0, getWidth(), getHeight());
|
||||||
|
|
||||||
|
// Dessin du fond
|
||||||
|
canvas.drawRoundRect(rect, radius, radius, paintFill);
|
||||||
|
|
||||||
|
// Dessin de la bordure
|
||||||
|
canvas.drawRoundRect(rect, radius, radius, paintBorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package com.example.q2_amyti;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
public class MainActivity extends Activity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user