开发过程中有很多弹窗需求,比如分享时弹窗,如下:
这其中就需要定义弹窗样式,位置等属性,要实现上述效果,可以通过两种比较常见的方式实现
1. 自定义dialog view 指定相关属性
2. 用dialog activity 去实现
上面实现的效果都会一样,总的来说就是要 一、自定义好view 二、控制弹出的位置
下面用dialog自定义的方式实现:
(1)定义view 的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/common_margin_default1"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/view_share_pengyou"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="@+id/share_icon"