Android開(kāi)發(fā)實(shí)現(xiàn)模仿微信小窗口功能【Dialog對(duì)話框風(fēng)格窗口】
本文實(shí)例講述了Android開(kāi)發(fā)實(shí)現(xiàn)模仿微信小窗口功能。分享給大家供大家參考,具體如下:
運(yùn)用方法:
將顯示窗口的風(fēng)格 設(shè)置為對(duì)話框風(fēng)格即可
具體效果:

具體實(shí)現(xiàn):
首先我們先定義布局文件:
<?xml version="1.0" encoding="utf-8" ?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/idtatabHost"
android:layout_width="300dp"
android:layout_height="500dp"
android:layout_gravity="center"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/wechat"
android:scaleType="fitXY"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="假的 WeChat"
android:textSize="20dp"
android:textColor="#ffffffff"/>
<Button
android:id="@+id/send"
android:onClick="send"
android:text="點(diǎn)我一下 有驚喜(嚇) 。。。"
android:textColor="#ffffffff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
然后我再活動(dòng)中照常設(shè)置監(jiān)聽(tīng)事件等方法:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void send(View source){
finish();
}
}
最重要的部分:
在未見(jiàn)的 mainfest.xml 中設(shè)置 活的的樣式為對(duì)話框風(fēng)格
具體如下:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Material.Dialog"
tools:targetApi="lollipop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
大功告成!
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《Android開(kāi)發(fā)入門(mén)與進(jìn)階教程》、《Android調(diào)試技巧與常見(jiàn)問(wèn)題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
相關(guān)文章
5種方法完美解決android軟鍵盤(pán)擋住輸入框方法詳解
我們?cè)陂_(kāi)發(fā)android APP中經(jīng)常會(huì)遇到鍵盤(pán)擋住輸入框的情況,必須先把鍵盤(pán)收起,再去獲取下面輸入框焦點(diǎn),這樣用戶體驗(yàn)也非常不好,今天就給大家介紹5種完美解決android鍵盤(pán)擋住輸入框的方法2018-03-03
Kotlin?Dispatchers協(xié)程調(diào)度器源碼深入分析
Kotlin協(xié)程不是什么空中閣樓,Kotlin源代碼會(huì)被編譯成class字節(jié)碼文件,最終會(huì)運(yùn)行到虛擬機(jī)中。所以從本質(zhì)上講,Kotlin和Java是類(lèi)似的,都是可以編譯產(chǎn)生class的語(yǔ)言,但最終還是會(huì)受到虛擬機(jī)的限制,它們的代碼最終會(huì)在虛擬機(jī)上的某個(gè)線程上被執(zhí)行2022-11-11
Android 給圖片加上水印的示例代碼(支持logo+文字)
本篇文章主要介紹了Android 給圖片加上水印的示例代碼(支持logo+文字),具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08
Android 搜索結(jié)果匹配關(guān)鍵字且高亮顯示功能
這篇文章主要介紹了Android 搜索結(jié)果匹配關(guān)鍵字且高亮顯示功能,需要的朋友可以參考下2017-05-05
android將搜索引擎設(shè)置為中國(guó)雅虎無(wú)法搜索問(wèn)題解決方法
android 進(jìn)入搜索,將搜索引擎設(shè)置為中國(guó)雅虎,無(wú)法搜索到相關(guān)網(wǎng)絡(luò)結(jié)果,該問(wèn)題是由于yahoo的搜索接口改變導(dǎo)致,具體解決方法如下,感興趣的朋友可以參考下哈2013-06-06
Android獲取手機(jī)號(hào)碼和運(yùn)營(yíng)商信息的方法
這篇文章主要介紹了Android獲取手機(jī)號(hào)碼和運(yùn)營(yíng)商信息的方法,以實(shí)例形式完整講述了獲取手機(jī)號(hào)碼和運(yùn)營(yíng)商信息的技巧,代碼中包含完整的注釋說(shuō)明,需要的朋友可以參考下2015-01-01
Flutter?SystemChrome控制應(yīng)用程序的系統(tǒng)級(jí)別行為
這篇文章主要為大家介紹了Flutter?SystemChrome用來(lái)控制應(yīng)用程序的系統(tǒng)級(jí)別行為步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05
Android應(yīng)用開(kāi)發(fā)中Fragment存儲(chǔ)功能的基本用法
這篇文章主要介紹了Android應(yīng)用開(kāi)發(fā)中使用Fragment存儲(chǔ)功能的基本用法,包括對(duì)Fragment的非中斷保存setRetaineInstance的講解,需要的朋友可以參考下2016-02-02
Android獲取短信驗(yàn)證碼的實(shí)現(xiàn)方法
為了保護(hù)用戶信息的安全性,開(kāi)始使用通過(guò)服務(wù)器向用戶發(fā)送驗(yàn)證碼的方式,接下來(lái)通過(guò)本文給大家介紹android獲取短信驗(yàn)證碼的實(shí)現(xiàn)方法,非常不錯(cuò),感興趣的朋友一起看看吧2016-09-09

