我正在运行一种类型的服务,SYSTEM_ALERT_WINDOW
并且我已经为服务增加了布局
private void createLayoutForServiceClass() {
inflater=(LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
windowManager=(WindowManager) getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
//WindowManager.LayoutParams.TYPE_INPUT_METHOD |
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,// | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.RIGHT | Gravity.TOP;
view = inflater.inflate(R.layout.area_selection, null);
windowManager.addView(view, params);
}
现在,当我设置布局的背景时,它返回给我黑色背景,我希望背景完全透明,以便用户可以看到它正在屏幕上运行,并且他/她可以在他/她不在时执行她的任务在做这项工作时感到不安。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B94765">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_cross"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="end"
android:src="@drawable/ic_close_black_24dp"/>
</LinearLayout>
<com.steelkiwi.cropiwa.CropIwaView
android:id="@+id/crop_view"
android:layout_width="match_parent"
android:layout_height="match_parent" /></LinearLayout>
是否可以将布局的背景设置为完全透明。我已经使活动透明,片段透明,对话框透明,但这对我来说是新的,任何人都可以建议我好主意
感谢你们对我的帮助。