欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android?WindowManager的簡單使用實例詳解

 更新時間:2023年08月31日 08:34:33   作者:玲瓏·  
這篇文章主要介紹了android?WindowManager的簡單使用,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

android WindowManager的簡單使用

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.App0"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
package com.koala.app0;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
    private static Context context;
    private Button button;
    private View imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context = getApplication().getApplicationContext();
        button = findViewById(R.id.btn1);
        imageView = LayoutInflater.from(context).inflate(R.layout.png,null);
        button.setOnClickListener(listener);
    }
    private View.OnClickListener listener =  new View.OnClickListener(){
        @Override
        public void onClick(View v) {
            WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
//            layoutParams.format = PixelFormat.RGBA_8888;
            layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
//            layoutParams.width = 200;
//            layoutParams.height = 200;
//            layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
//            layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
            layoutParams.x = 30;
            layoutParams.y = 40;
            WindowManager windowManager = getWindowManager();
            windowManager.addView(imageView,layoutParams);
        }
    };
    public static Context getContext(){
        return context;
    }
}

到此這篇關于android WindowManager的簡單使用的文章就介紹到這了,更多相關android WindowManager使用內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Android實現(xiàn)圖片高斯模糊

    Android實現(xiàn)圖片高斯模糊

    這篇文章主要為大家詳細介紹了Android實現(xiàn)圖片高斯模糊,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • android開發(fā)socket編程之udp發(fā)送實例分析

    android開發(fā)socket編程之udp發(fā)送實例分析

    這篇文章主要介紹了android開發(fā)socket編程之udp發(fā)送,實例分析了Android開發(fā)socket網(wǎng)絡編程中udp發(fā)送的相關技巧,非常具有實用價值,需要的朋友可以參考下
    2015-04-04
  • Android 實現(xiàn)ListView的點擊變色的實例

    Android 實現(xiàn)ListView的點擊變色的實例

    這篇文章主要介紹了Android 實現(xiàn)ListView的點擊變色的實例的相關資料,主要實現(xiàn)Android listveiw ItemClickListener寫入變色的功能,需要的朋友可以參考下
    2017-07-07
  • Android加密之全盤加密詳解

    Android加密之全盤加密詳解

    這篇文章主要介紹了Android加密之全盤加密詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • Android實現(xiàn)的可以調整透明度的圖片查看器實例

    Android實現(xiàn)的可以調整透明度的圖片查看器實例

    這篇文章主要介紹了Android實現(xiàn)的可以調整透明度的圖片查看器,需要的朋友可以參考下
    2014-07-07
  • 百度地圖API提示230 錯誤app scode碼校驗失敗的解決辦法

    百度地圖API提示230 錯誤app scode碼校驗失敗的解決辦法

    筆者近2天在 Android Studio上玩了一下百度地圖,碰到了常見的"230錯誤 APP Scode校驗失敗",下面我來介紹一下具體的解決辦法
    2016-01-01
  • Android仿微信鍵盤切換效果

    Android仿微信鍵盤切換效果

    這篇文章主要為大家詳細介紹了Android仿微信鍵盤切換效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • Android客戶端post請求服務器端實例

    Android客戶端post請求服務器端實例

    這篇文章主要介紹了Android客戶端post請求服務器端實例,本文講解了Android客戶端與服務器端通信方式、解析服務器端返回數(shù)據(jù)的解釋、用GET和POST訪問http資源等內容,并給出了一個POST實例,需要的朋友可以參考下
    2015-06-06
  • 超簡單Android集成華為HMS Scankit 掃碼SDK實現(xiàn)掃一掃二維碼

    超簡單Android集成華為HMS Scankit 掃碼SDK實現(xiàn)掃一掃二維碼

    這篇文章主要介紹了超簡單Android集成華為HMS Scankit 掃碼SDK實現(xiàn)掃一掃二維碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-03-03
  • Android小程序實現(xiàn)訪問聯(lián)系人

    Android小程序實現(xiàn)訪問聯(lián)系人

    這篇文章主要為大家詳細介紹了Android小程序實現(xiàn)訪問聯(lián)系人,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一
    2020-05-05

最新評論