Android类似QQ弹窗效果
来源:互联网 发布:设计头像软件 编辑:程序博客网 时间:2024/06/07 05:57
QQ的消息提醒有通知栏的还有弹出对话框的,怎么样才能有这种效果:
我是这样做的,不知道对不对,希望大家互相学习。
1.布局文件照着他这样做,代码:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/father" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.administrator.changeactivityproprety.MainActivity"> <RelativeLayout android:id="@+id/rl1" android:background="@color/colorPrimaryDark" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher" /> <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="99" android:layout_toRightOf="@+id/imageview" android:layout_marginTop="15dp" android:layout_marginLeft="15dp" android:textColor="@android:color/white" android:textSize="18dp"/> <ImageView android:layout_alignParentRight="true" android:paddingTop="15dp" android:paddingRight="15dp" android:layout_height="30dp" android:layout_width="30dp" android:src="@drawable/closeha"/> </RelativeLayout> <RelativeLayout android:background="@color/colorPrimary" android:layout_below="@id/rl1" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_marginTop="15dp" android:id="@+id/line1" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:textColor="@android:color/white" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="李煤" android:textSize="20dp" /> <TextView android:layout_marginTop="10dp" android:layout_marginRight="15dp" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="15:45"/> </RelativeLayout> <RelativeLayout android:id="@+id/relat1" android:layout_marginTop="5dp" android:layout_below="@id/line1" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="* 你说啥"/> </RelativeLayout> <RelativeLayout android:layout_below="@id/relat1" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_margin="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> </RelativeLayout> </RelativeLayout></RelativeLayout>
实际的话,消息的哪条一般用ListView替代。
在主活动代码中修改窗口的参数,代码:
package com.example.administrator.changeactivityproprety;import android.app.Activity;import android.os.Process;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.Gravity;import android.view.Window;import android.view.WindowManager;import android.widget.RelativeLayout;import android.widget.SeekBar;public class MainActivity extends Activity{ RelativeLayout relativeLayout; WindowManager.LayoutParams layoutParams; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); layoutParams= getWindow().getAttributes(); relativeLayout= (RelativeLayout) findViewById(R.id.father); layoutParams.alpha=0.9f; layoutParams.height=400; getWindow().setAttributes(layoutParams); }}只是简单的改变了窗口的高度,还有透明度。
因为Activity后面,还有一层视图,如果不设置,其他部分回事黑色,不能呈现效果
所以:在style.xml中加入自己的style,使它透明
<style name="Transparent"> <item name="android:windowIsTranslucent">true</item></style>然后在主配置文件中添加主题
<activity android:name=".MainActivity" android:theme="@style/Transparent"运行效果:
布局中用到的图片,可以随便换
0 0
- Android类似QQ弹窗效果
- 类似 qq 切换效果
- listview 弹窗效果实现 +类似qq的滑动删除效果
- 实现 类似 Android Market || QQ 横屏滚动 的 效果
- android expandablelistview--实现类似qq界面的效果
- Android实现类似QQ的滑动删除效果
- Android实现类似QQ的滑动删除效果
- Android实现类似QQ的滑动删除效果
- android自定义控件SlidingButtonView实现类似QQ滑动删除效果
- Android 自定义实现类似QQ消息贝塞尔拖拽效果BezierView
- 类似QQ相册的效果
- 【Android进阶】多抽屉效果 (类似最早QQ使用的效果)
- 【Android进阶】多抽屉效果 (类似最早QQ使用的效果)
- 【Android进阶】多抽屉效果 (类似最早QQ使用的效果)
- Android多抽屉效果 (类似最早QQ使用的效果)
- android RecyclerView一步步打造分组效果、类似QQ分组、折叠菜单、分组效果(一)
- android RecyclerView一步步打造分组效果、类似QQ分组、折叠菜单、分组效果(二)
- 类似qq的窗体停靠效果(未果)
- (一)SOLR学习资料整理——solr简介
- Kali 2.0 采用ssh连接登陆
- HttpURLConnection用法详解
- java中抽象类和接口之间的区别和关系
- 设置RecyclerView 移动到底部
- Android类似QQ弹窗效果
- 使用haproxy做tcp 层的负载均衡
- Navicat导入数据到数据库中碰到的问题
- 创建目录
- linux的进程与线程
- CentOS 6.5/6.6 安装mysql 5.7
- Android学习笔记——界面相关逻辑
- 循环队列
- 浅谈Eclipse调用Tomcat服务的原理 .