最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android?WindowManager的簡(jiǎn)單使用實(shí)例詳解

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

android WindowManager的簡(jiǎn)單使用

<?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;
    }
}

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

相關(guān)文章

  • Flutter開發(fā)之動(dòng)態(tài)權(quán)限的使用

    Flutter開發(fā)之動(dòng)態(tài)權(quán)限的使用

    眾所周知,Android在6.0版本后將權(quán)限修改成了動(dòng)態(tài)權(quán)限,而iOS則一直使用的是動(dòng)態(tài)權(quán)限,所以在Flutter應(yīng)用開發(fā)中如果涉及到一些危險(xiǎn)權(quán)限,就需要進(jìn)行動(dòng)態(tài)申請(qǐng),本文就詳細(xì)的介紹一下,感興趣的可以了解一下
    2021-09-09
  • android如何獲取textview最多顯示

    android如何獲取textview最多顯示

    今天在公司遇到一個(gè)需求;TextView設(shè)置最多顯示8個(gè)字符,超過部分顯示...(省略號(hào)),那么android如何獲取textview最多顯示,感興趣的可以了解一下
    2021-06-06
  • listview里子項(xiàng)有按鈕的情況使用介紹

    listview里子項(xiàng)有按鈕的情況使用介紹

    不知大家有沒有遇到過listview里子項(xiàng)有按鈕的情況哈,本文自定義了按鈕并且在布局中做了引用,適合初學(xué)者哦,感興趣的也可以了解下
    2013-03-03
  • Android編程之播放器MediaPlayer實(shí)現(xiàn)均衡器效果示例

    Android編程之播放器MediaPlayer實(shí)現(xiàn)均衡器效果示例

    這篇文章主要介紹了Android編程之播放器MediaPlayer實(shí)現(xiàn)均衡器效果,結(jié)合具體實(shí)例形式分析了Android調(diào)用MediaPlayer相關(guān)API構(gòu)造均衡器的具體步驟與相關(guān)功能實(shí)現(xiàn)方法,需要的朋友可以參考下
    2017-08-08
  • Android實(shí)現(xiàn)拍照、錄像、錄音代碼范例

    Android實(shí)現(xiàn)拍照、錄像、錄音代碼范例

    這篇文章主要介紹了Android實(shí)現(xiàn)拍照、錄像、錄音代碼的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2016-10-10
  • Android里實(shí)現(xiàn)退出主程序的提示代碼

    Android里實(shí)現(xiàn)退出主程序的提示代碼

    當(dāng)用戶選擇"確定",就退出當(dāng)前的對(duì)話框。其中,有個(gè)很重要的函數(shù),Activity.finish(),通過調(diào)用這個(gè)函數(shù),退出當(dāng)前運(yùn)行的整個(gè)Android程序
    2013-06-06
  • Android 高版本API方法在低版本系統(tǒng)上的兼容性處理

    Android 高版本API方法在低版本系統(tǒng)上的兼容性處理

    本文主要介紹Android 高版本API方法在低版本系統(tǒng)上的兼容性處理的問題,這里提供了解決辦法,并附簡(jiǎn)單示例,來詳細(xì)說明解決問題步驟,有需要的小伙伴可以參考下
    2016-09-09
  • Android Broadcast 和 BroadcastReceiver的權(quán)限限制方式

    Android Broadcast 和 BroadcastReceiver的權(quán)限限制方式

    這篇文章主要介紹了Android Broadcast 和 BroadcastReceiver的權(quán)限限制方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • Android實(shí)現(xiàn)簡(jiǎn)易記事本

    Android實(shí)現(xiàn)簡(jiǎn)易記事本

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡(jiǎn)易記事本,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-07-07
  • Android自定義分段式進(jìn)度條

    Android自定義分段式進(jìn)度條

    這篇文章主要為大家詳細(xì)介紹了Android自定義分段式進(jìn)度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-04-04

最新評(píng)論

哈尔滨市| 若尔盖县| 尤溪县| 锦州市| 凤阳县| 乌鲁木齐县| 宁夏| 永州市| 孝昌县| 嘉禾县| 吉首市| 琼结县| 城步| 囊谦县| 永寿县| 丰城市| 巢湖市| 尚义县| 米泉市| 靖西县| 苍梧县| 天津市| 利川市| 金昌市| 马关县| 饶平县| 印江| 广南县| 邳州市| 新河县| 锦州市| 许昌县| 新宁县| 望城县| 平果县| 镇巴县| 龙胜| 福海县| 文安县| 牙克石市| 阳山县|