国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android開發實現模仿微信小窗口功能【Dialog對話框風格窗口】

2019-10-21 21:19:17
字體:
來源:轉載
供稿:網友

本文實例講述了Android開發實現模仿微信小窗口功能。分享給大家供大家參考,具體如下:

運用方法:

將顯示窗口的風格 設置為對話框風格即可

具體效果:

Android開發,微信小窗口,Dialog,對話框

具體實現:

首先我們先定義布局文件:

<?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="點我一下 有驚喜(嚇) 。。。"    android:textColor="#ffffffff"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:layout_alignParentBottom="true"/></RelativeLayout>

然后我再活動中照常設置監聽事件等方法:

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 中設置 活的的樣式為對話框風格

具體如下:

  <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>

大功告成!

希望本文所述對大家Android程序設計有所幫助。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 伊金霍洛旗| 华坪县| 石柱| 腾冲县| 万载县| 平邑县| 新邵县| 阜新市| 兴义市| 墨玉县| 怀仁县| 子洲县| 大石桥市| 吉木乃县| 德化县| 房山区| 神木县| 巴林左旗| 荔波县| 通河县| 揭阳市| 磐石市| 新乡县| 晴隆县| 枝江市| 新化县| 德阳市| 荥经县| 惠水县| 新建县| 南汇区| 瑞安市| 阜平县| 伽师县| 平果县| 青阳县| 邛崃市| 石泉县| 乌兰县| 涞源县| 沧源|