Android: Overlay Textview auf Lockscreen
Im ein Textview auf dem Lockscreen (ähnlich wie Android Overlays die Zeit) zu überlagern versuchen.
Hinweis: Ich möchte den Lockscreen nicht umgehen, sondern nur darüber zeichnen (ohne die Berührungsereignisse zu beeinträchtigen).
Ich habe versucht, die folgenden Flags verwendet (in onCreate):
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
getWindow().addFlags(PixelFormat.TRANSLUCENT);
und Anwendung der folgenden Themen (auf die spezifische Aktivität):
<style name="Transparent">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowActionBar">false</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowIsFloating">true</item>
</style>
Aber das zieht oben auf dem Sperrbildschirm, der den Sperrbildschirm versteckt und alle Berührungsereignisse deaktiviert.
Edit: activity_overlay.xml
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.coco.MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:layout_alignParentBottom="true"
android:text="TextView" />
</RelativeLayout>
Manifest Erklärung Aktivität (die overlay_activity.xml aufbläst)
<activity
android:name=".DisplayActivity"
android:label="@string/app_name"
android:theme="@style/Transparent" />
Können Sie Ihre tatsächliche Layoutdatei anzeigen? – marktani
@mcwise Die Layoutdatei hinzugefügt. activity_overlay.xml. Auch die Manifest-Deklaration hinzugefügt – Zen
Ich habe alle Kombinationen von Theme & Flags ausprobiert, aber keine gibt die gewünschte Überlagerung. Auch versucht, die Flags von onCreate und onWindowFocusChanged – Zen