Android開發(fā)實(shí)現(xiàn)模仿微信小窗口功能【Dialog對話框風(fēng)格窗口】
本文實(shí)例講述了Android開發(fā)實(shí)現(xiàn)模仿微信小窗口功能。分享給大家供大家參考,具體如下:
運(yùn)用方法:
將顯示窗口的風(fēng)格 設(shè)置為對話框風(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>
然后我再活動中照常設(shè)置監(jiān)聽事件等方法:
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();
}
}
最重要的部分:
在未見的 mainfest.xml 中設(shè)置 活的的樣式為對話框風(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)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對大家Android程序設(shè)計有所幫助。
相關(guān)文章
Android自定義控件實(shí)現(xiàn)通用驗(yàn)證碼輸入框(二)
這篇文章主要為大家詳細(xì)介紹了Android自定義控件實(shí)現(xiàn)通用驗(yàn)證碼輸入框的第二篇,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-01-01
詳解Android如何設(shè)計一個全局可調(diào)用的ViewModel對象
很多時候我們需要維護(hù)一個全局可用的ViewModel,因?yàn)檫@樣可以維護(hù)全局同一份數(shù)據(jù)源,且方便使用協(xié)程綁定App的生命周期,那如何設(shè)計全局可用的ViewModel對象,文中介紹的非常詳細(xì),需要的朋友可以參考下2023-05-05
Android Studio 導(dǎo)入新工程項(xiàng)目圖解
這篇文章主要介紹了Android Studio 導(dǎo)入新工程項(xiàng)目圖解,需要的朋友可以參考下2017-12-12
Android中ActionBar以及menu的代碼設(shè)置樣式
這篇文章主要介紹了Android中ActionBar以及menu的代碼設(shè)置樣式的相關(guān)資料,需要的朋友可以參考下2015-07-07
android view轉(zhuǎn)Bitmap生成截圖的方法
這篇文章主要介紹了android view轉(zhuǎn)Bitmap生成截圖的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-09-09
Android獲取短信驗(yàn)證碼的實(shí)現(xiàn)方法
為了保護(hù)用戶信息的安全性,開始使用通過服務(wù)器向用戶發(fā)送驗(yàn)證碼的方式,接下來通過本文給大家介紹android獲取短信驗(yàn)證碼的實(shí)現(xiàn)方法,非常不錯,感興趣的朋友一起看看吧2016-09-09
Android中的RecyclerView新組件初步上手指南
RecyclerView是Android L版本開始采用的一個組件,被人們認(rèn)為用來代替?zhèn)鹘y(tǒng)的ListView,下面我們就一起來看一下Android中的RecyclerView新組件初步上手指南2016-06-06

