Ich versuche, ein Popup-Fenster mit abgerundeten Kanten zu erstellen. Ich habe gesehen, dass es vor einem Jahr eine ähnliche Frage gibt, mit vielen Antworten, die ich ausprobiert habe und von denen keines das Problem löst. Letztendlich erstelle ich eine Aktivität, die selbst gekrümmte Kanten hat, jedoch gibt es einen weißen Hintergrund, der Ecken darunter hat, so dass der Effekt nicht funktioniert. Außerdem versuche ich, dies über meine andere Aktivität mit Intents anzuzeigen, aber dies erzeugt einen ganz neuen Bildschirm und macht den nicht von der Aktivität eingenommenen Raum schwarz. Ich schätze die Hilfe sehr, danke. Gekrümmte Kanten auf Aktivität Android
XML-Format:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners
android:radius="25dp"
/>
<solid
android:color="@color/GreenYellow"/>
</shape>
JAVA-Code Initialisierung des Fensters:
confirmLayout = (RelativeLayout) findViewById(R.id.confirm_window);
getWindow().setLayout(width,height);
confirmLayout.setGravity(RelativeLayout.CENTER_VERTICAL);
confirmLayout.setBackgroundResource(R.drawable.justcurves);
XML für Fenster selbst:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/confirm_window"
tools:context="com.exampleryancocuzzo.ryan.markettycoon.ConfirmWindow"
android:background="@color/GreenYellow"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Press Confirm to proceed"
android:textSize="25sp"
android:gravity="center"
android:textStyle="bold"
android:layout_centerVertical="true"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Confirm"
android:padding="10dp"
android:layout_alignParentBottom="true"
android:layout_margin="5dp"
android:textColor="@color/White"
android:background="@color/Black"
android:onClick="confirmed"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:padding="10dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:textColor="@color/White"
android:background="@color/DarkGray"
android:onClick="cancelled"
/>
</RelativeLayout>
ich dieses Konzept versucht, und ich habe eine IllegalStateException dafür erhalten, kein Theme.AppCompat Theme in der Aktivität –
zu verwenden. Du musst deine Aktivitätsklasse auf 'android.app.Activity' erweitern oder die zweite Option ist' android: Theme.Dialog' in styles.xml mit 'zu ersetzen Theme.AppCompat.Light.Dialog' –