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

发布时间:2019-08-08 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Android开发实现模仿微信小窗口功能【Dialog对话框风格窗口】脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了AndROId开发实现模仿微信小窗口功能。分享给大家供大家参考,具体如下:

运用方法:

将显示窗口的风格 设置为对话框风格即可

具体效果:

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

具体实现:

首先我们先定义布局文件:

 <&#63;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开发入门与进阶教程》、《Android调试技巧与常见问题解决方法汇总》、《Android基本组件用法总结》、《Android视图View技巧总结》、《Android布局layout技巧总结》及《Android控件用法总结

android教程
脚本网站
android studio

脚本宝典总结

以上是脚本宝典为你收集整理的Android开发实现模仿微信小窗口功能【Dialog对话框风格窗口】全部内容,希望文章能够帮你解决Android开发实现模仿微信小窗口功能【Dialog对话框风格窗口】所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。