Android开发实现模仿微信小窗口功能【Dialog对话框风格窗口】

作者:水中鱼之1999 时间:2022-01-27 10:11:01 

本文实例讲述了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程序设计有所帮助。

来源:https://blog.csdn.net/qq_43377749/article/details/85037821

标签:Android,微信,Dialog对话框
0
投稿

猜你喜欢

  • Java 1.0和Java 1.1 的IO类的比较

    2023-10-07 10:48:39
  • 四步五分钟Spring4快速集成Swagger

    2022-02-18 08:24:15
  • Spring-Data-JPA整合MySQL和配置的方法

    2023-10-29 10:19:41
  • Java实现的简单音乐播放器功能示例

    2021-08-06 20:06:54
  • 解决IDEA中maven导入jar包一直报错问题

    2021-12-26 11:52:22
  • Java中notify和notifyAll的区别及何时使用

    2022-07-03 02:08:43
  • c#数据的序列化和反序列化(推荐版)

    2022-03-27 22:55:56
  • java实现List中对象排序的方法

    2023-11-08 21:36:29
  • Spring启动过程中实例化部分代码的分析之Bean的推断构造方法

    2022-08-26 02:00:07
  • java.lang.String类的使用

    2021-12-11 03:57:26
  • 基于Mybatis映射的一点心得(分享)

    2023-08-08 13:15:53
  • Java基础之详解HashSet的使用方法

    2023-08-04 20:18:59
  • springboot注册bean的三种方法

    2023-11-22 21:57:12
  • 初学C#所需明白的那些点

    2023-11-26 14:40:50
  • java开发微信公众号支付

    2021-10-24 16:02:40
  • C#算法之整数反转

    2021-09-24 18:36:49
  • Scala方法与函数使用和定义详解

    2021-10-05 06:34:12
  • 基于运算符重载的那些事

    2023-03-29 01:50:51
  • jdk源码阅读Collection详解

    2022-07-25 08:57:40
  • 详解HDFS多文件Join操作的实例

    2023-09-20 07:44:14
  • asp之家 软件编程 m.aspxhome.com