什么是WindowAndroid?
我认为Android中的最高级别被调用Activity,这是你看到的屏幕.
有人能告诉我Android中的Window是什么吗?我们只有一个或多个.
是否可以以编程方式枚举android.view.Window应用程序中的所有s或装饰视图?
Dialogs例如,它们都将在一个新的中打开Window,与主Activity窗口分开.我可以通过Dialog.getWindow()它找到它们,但我不确定如何使用内置组件(如活动菜单弹出窗口)执行此操作.
有什么办法,从Application,Context或者WindowManager,还是其他什么东西,枚举与我的应用程序关联的Windows?
我可以看到我的所有应用程序的窗口adb dumpsys window,但我正在寻找一种方法在我的应用程序中执行此操作而不需要root.
如何滑入键盘?我试过:
val keyboardController: SoftwareKeyboardController? = LocalSoftwareKeyboardController.current
keyboardController?.show()
Run Code Online (Sandbox Code Playgroud)
但这不起作用。我缺少什么?也许一些清单标志?
android-windowmanager android-window android-jetpack android-jetpack-compose
我试图显示一个带有match_parent的DialogFragment高度和宽度,但它发生在顶部,DialogFragment显示在StatusBar下面.
DialogFragment在底部,右侧,左侧和顶部应用了一些默认值.但顶部填充应从statusBar开始计数,而不是从总屏幕大小开始计算.
如何将DialogFragment设置为match_parent,但是在顶部,底部,右侧,左侧具有正常/默认填充?
android android-dialog android-windowmanager android-dialogfragment android-window
我通过mWindowManager.addview(). 现在我想知道是否有可能获得window实例。他们是myView.getWindowID(),myView.getWindowToken()但我找不到从中检索窗口实例的方法
以下图片是应用https://play.google.com/store/apps/details?id=jp.snowlife01.android.clipboard的窗口.我把它命名为主窗口.
似乎主窗口不是普通窗口.它位于其他窗口的顶部,主窗口无法移动.
当我单击主窗口中的最小化按钮时,将显示一个小点图标,可以移动小点图标,单击小点图标时可以恢复主窗口.
我认为小点图标是一个SYSTEM_ALERT_WINDOW,但主窗口怎么样?
图片
我有MainActivity很多Fragments 并且在一个特定的片段中我想在系统栏后面绘制,所以我在运行时应用以下标志:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
Run Code Online (Sandbox Code Playgroud)
我现在想要的是当用户退出Fragment并输入另一个以删除该标志时,状态栏后面没有内容。我尝试将 null 作为参数传递给setFlags()方法,但这给出了错误。我已经搜索remove()或unSet()方法,但不存在。那么我应该如何删除另一个标志Fragment?
我想操纵状态栏(ex.color)但在后台.我正在使用前台服务来执行此操作.因此,没有窗口,因为它在后台发生,特别是没有活动.但是,功能
public abstract void setStatusBarColor (int color)
Run Code Online (Sandbox Code Playgroud)
由抽象类Window调用:https://developer.android.com/reference/android/view/Window.html
所以因为它是抽象的我无法启动它而且我不能使用getWindow()因为我没有实现一个活动类.以下答案使用Activity.还有其他方法可以实现吗? 如何更改android中的状态栏颜色
android statusbar android-windowmanager android-statusbar android-window
我的任务是通过良好的嵌入(库变体)接收android应用程序中的所有运动事件。我创建了Window.Callback包装器。
public class WindowCallback implements Window.Callback {
private final Window.Callback wrapper;
public WindowCallback(Window.Callback callback) {
this.wrapper = callback;
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
return wrapper.dispatchKeyEvent(event);
}
@Override
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
return wrapper.dispatchKeyShortcutEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
return wrapper.dispatchTouchEvent(event);
}
// other methods omitted
}
Run Code Online (Sandbox Code Playgroud)
然后,在中实例化它Activity:
final Window window = getWindow();
final Window.Callback windowCallback = window.getCallback();
final WindowCallback callbackWrapper = new WindowCallback(windowCallback);
window.setCallback(interceptCallback);
Run Code Online (Sandbox Code Playgroud)
但是当我Toolbar进入时Activity,此方法或方法将Toolbar捕获。框架中的代码片段:Window.CallbacksetActionBar(Toolbar) …
android android-support-library android-toolbar android-window
我想尝试长按一下EditText,但是当我做长按时,我会收到以下错误.我希望能够长按一次以获取"复制/粘贴/全选"上下文弹出窗口,以便用户可以将文本粘贴到框中.
Fatal Exception: android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@799bfc6 is not valid; is your activity running?
Run Code Online (Sandbox Code Playgroud)
EditText位于PopupWindow的ScrollView中.因此,当错误发生时,我当前在PopupWindow打开的Activity上处于活动状态,并且我在PopupWindow中包含的EditText中进行长按.
Gradle设置
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId 'com.accoservice.cico'
minSdkVersion 17
targetSdkVersion 25
versionCode 37
versionName '4.2.6'
multiDexEnabled true
}
Run Code Online (Sandbox Code Playgroud)
包含EditText的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/outer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#73000000">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="100dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"
android:singleLine="true"
android:text="@string/note_msg"
android:textColor="#62CCFE"
android:textSize="18sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:background="#62CCFE" />
<ScrollView
android:id="@+id/sv_resolution_note"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) android android-layout android-view android-windowmanager android-window