转载出处http://blog.csdn.net/nugongahou110

通常我们使用dialog的时候会遇到一些问题,比如我想用自己定义的布局来替代系统那个黑乎乎的布局时我要怎么做?我想要指定dialog从底部弹出而不是在屏幕中央弹出要怎么做?我设置了dialog布局的宽度为填充父窗体然而实际效果却不是充满全屏的,这时我该怎么做?

我们先来看一个例子:

首先我们先来定义一个dialog的布局

<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);">  1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);">  2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);">  3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);">  4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);">  5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L6" rel="#L6" style="text-decoration: none; color: rgb(12, 137, 207);">  6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L7" rel="#L7" style="text-decoration: none; color: rgb(12, 137, 207);">  7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L8" rel="#L8" style="text-decoration: none; color: rgb(12, 137, 207);">  8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L9" rel="#L9" style="text-decoration: none; color: rgb(12, 137, 207);">  9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L10" rel="#L10" style="text-decoration: none; color: rgb(12, 137, 207);"> 10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L11" rel="#L11" style="text-decoration: none; color: rgb(12, 137, 207);"> 11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L12" rel="#L12" style="text-decoration: none; color: rgb(12, 137, 207);"> 12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L13" rel="#L13" style="text-decoration: none; color: rgb(12, 137, 207);"> 13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L14" rel="#L14" style="text-decoration: none; color: rgb(12, 137, 207);"> 14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L15" rel="#L15" style="text-decoration: none; color: rgb(12, 137, 207);"> 15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L16" rel="#L16" style="text-decoration: none; color: rgb(12, 137, 207);"> 16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L17" rel="#L17" style="text-decoration: none; color: rgb(12, 137, 207);"> 17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L18" rel="#L18" style="text-decoration: none; color: rgb(12, 137, 207);"> 18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L19" rel="#L19" style="text-decoration: none; color: rgb(12, 137, 207);"> 19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L20" rel="#L20" style="text-decoration: none; color: rgb(12, 137, 207);"> 20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L21" rel="#L21" style="text-decoration: none; color: rgb(12, 137, 207);"> 21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L22" rel="#L22" style="text-decoration: none; color: rgb(12, 137, 207);"> 22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L23" rel="#L23" style="text-decoration: none; color: rgb(12, 137, 207);"> 23</a>
<a target=_blank id="L24" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L24" rel="#L24" style="text-decoration: none; color: rgb(12, 137, 207);"> 24</a>
<a target=_blank id="L25" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L25" rel="#L25" style="text-decoration: none; color: rgb(12, 137, 207);"> 25</a>
<a target=_blank id="L26" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L26" rel="#L26" style="text-decoration: none; color: rgb(12, 137, 207);"> 26</a>
<a target=_blank id="L27" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L27" rel="#L27" style="text-decoration: none; color: rgb(12, 137, 207);"> 27</a>
<a target=_blank id="L28" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L28" rel="#L28" style="text-decoration: none; color: rgb(12, 137, 207);"> 28</a>
           
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="@+id/bt_weixin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="微信"
android:layout_weight="1"
android:background="@color/material_blue_grey_800"/>
<Button
android:id="@+id/bt_weibo"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#ef3254"
android:text="微博"/>
<Button
android:id="@+id/bt_pengyouquan"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#ef6d03"
android:text="朋友圈"/>
</LinearLayout>

来自CODE的代码片
my_dialog.xml

activity_main.xml非常简单,只有一个button

<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);">  1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);">  2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);">  3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);">  4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);">  5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L6" rel="#L6" style="text-decoration: none; color: rgb(12, 137, 207);">  6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L7" rel="#L7" style="text-decoration: none; color: rgb(12, 137, 207);">  7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L8" rel="#L8" style="text-decoration: none; color: rgb(12, 137, 207);">  8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L9" rel="#L9" style="text-decoration: none; color: rgb(12, 137, 207);">  9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L10" rel="#L10" style="text-decoration: none; color: rgb(12, 137, 207);"> 10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L11" rel="#L11" style="text-decoration: none; color: rgb(12, 137, 207);"> 11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L12" rel="#L12" style="text-decoration: none; color: rgb(12, 137, 207);"> 12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L13" rel="#L13" style="text-decoration: none; color: rgb(12, 137, 207);"> 13</a>
           
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="@+id/share"
android:text="分享" android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>

来自CODE的代码片
activity_main.xml

接着我们要在res/values/styles.xml下定义dialog的样式以及dialog弹出时的动画

<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);">  1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);">  2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);">  3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);">  4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);">  5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L6" rel="#L6" style="text-decoration: none; color: rgb(12, 137, 207);">  6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L7" rel="#L7" style="text-decoration: none; color: rgb(12, 137, 207);">  7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L8" rel="#L8" style="text-decoration: none; color: rgb(12, 137, 207);">  8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L9" rel="#L9" style="text-decoration: none; color: rgb(12, 137, 207);">  9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L10" rel="#L10" style="text-decoration: none; color: rgb(12, 137, 207);"> 10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L11" rel="#L11" style="text-decoration: none; color: rgb(12, 137, 207);"> 11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L12" rel="#L12" style="text-decoration: none; color: rgb(12, 137, 207);"> 12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L13" rel="#L13" style="text-decoration: none; color: rgb(12, 137, 207);"> 13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L14" rel="#L14" style="text-decoration: none; color: rgb(12, 137, 207);"> 14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L15" rel="#L15" style="text-decoration: none; color: rgb(12, 137, 207);"> 15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L16" rel="#L16" style="text-decoration: none; color: rgb(12, 137, 207);"> 16</a>
           
<!-- 弹出框动画 由下至上 -->
<style name="dialogStyle" parent="@android:style/Animation.Dialog">
<item name="@android:windowEnterAnimation">@anim/dialog_enter</item>
<!-- 进入时的动画 -->
<item name="@android:windowExitAnimation">@anim/dialog_exit</item>
<!-- 退出时的动画 -->
</style>
<!-- 对话框样式 -->
<style name="Theme.Light.Dialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:scrollHorizontally">true</item>
</style>

来自CODE的代码片
styles.xml

接着我们在res下新建一个anim文件夹,在res/values/anim下新建两个xml文件

dialog_enter.xml和dialog_exit.xml如下

<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);"> 1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);"> 2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);"> 3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);"> 4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);"> 5</a>
           
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="100%"
android:duration="600"></translate>
</set>

来自CODE的代码片
dialog_enter.xml

<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);"> 1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);"> 2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);"> 3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);"> 4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);"> 5</a>
           
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:toYDelta="100%"
android:duration="600"></translate>
</set>

来自CODE的代码片
dialog_exit.xml

最后是MainActivity.Java

<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);">  1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);">  2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);">  3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);">  4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);">  5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L6" rel="#L6" style="text-decoration: none; color: rgb(12, 137, 207);">  6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L7" rel="#L7" style="text-decoration: none; color: rgb(12, 137, 207);">  7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L8" rel="#L8" style="text-decoration: none; color: rgb(12, 137, 207);">  8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L9" rel="#L9" style="text-decoration: none; color: rgb(12, 137, 207);">  9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L10" rel="#L10" style="text-decoration: none; color: rgb(12, 137, 207);"> 10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L11" rel="#L11" style="text-decoration: none; color: rgb(12, 137, 207);"> 11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L12" rel="#L12" style="text-decoration: none; color: rgb(12, 137, 207);"> 12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L13" rel="#L13" style="text-decoration: none; color: rgb(12, 137, 207);"> 13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L14" rel="#L14" style="text-decoration: none; color: rgb(12, 137, 207);"> 14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L15" rel="#L15" style="text-decoration: none; color: rgb(12, 137, 207);"> 15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L16" rel="#L16" style="text-decoration: none; color: rgb(12, 137, 207);"> 16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L17" rel="#L17" style="text-decoration: none; color: rgb(12, 137, 207);"> 17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L18" rel="#L18" style="text-decoration: none; color: rgb(12, 137, 207);"> 18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L19" rel="#L19" style="text-decoration: none; color: rgb(12, 137, 207);"> 19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L20" rel="#L20" style="text-decoration: none; color: rgb(12, 137, 207);"> 20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L21" rel="#L21" style="text-decoration: none; color: rgb(12, 137, 207);"> 21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L22" rel="#L22" style="text-decoration: none; color: rgb(12, 137, 207);"> 22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L23" rel="#L23" style="text-decoration: none; color: rgb(12, 137, 207);"> 23</a>
<a target=_blank id="L24" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L24" rel="#L24" style="text-decoration: none; color: rgb(12, 137, 207);"> 24</a>
<a target=_blank id="L25" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L25" rel="#L25" style="text-decoration: none; color: rgb(12, 137, 207);"> 25</a>
<a target=_blank id="L26" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L26" rel="#L26" style="text-decoration: none; color: rgb(12, 137, 207);"> 26</a>
<a target=_blank id="L27" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L27" rel="#L27" style="text-decoration: none; color: rgb(12, 137, 207);"> 27</a>
<a target=_blank id="L28" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L28" rel="#L28" style="text-decoration: none; color: rgb(12, 137, 207);"> 28</a>
<a target=_blank id="L29" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L29" rel="#L29" style="text-decoration: none; color: rgb(12, 137, 207);"> 29</a>
<a target=_blank id="L30" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L30" rel="#L30" style="text-decoration: none; color: rgb(12, 137, 207);"> 30</a>
<a target=_blank id="L31" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L31" rel="#L31" style="text-decoration: none; color: rgb(12, 137, 207);"> 31</a>
<a target=_blank id="L32" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L32" rel="#L32" style="text-decoration: none; color: rgb(12, 137, 207);"> 32</a>
<a target=_blank id="L33" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L33" rel="#L33" style="text-decoration: none; color: rgb(12, 137, 207);"> 33</a>
<a target=_blank id="L34" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L34" rel="#L34" style="text-decoration: none; color: rgb(12, 137, 207);"> 34</a>
<a target=_blank id="L35" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L35" rel="#L35" style="text-decoration: none; color: rgb(12, 137, 207);"> 35</a>
<a target=_blank id="L36" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L36" rel="#L36" style="text-decoration: none; color: rgb(12, 137, 207);"> 36</a>
<a target=_blank id="L37" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L37" rel="#L37" style="text-decoration: none; color: rgb(12, 137, 207);"> 37</a>
<a target=_blank id="L38" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L38" rel="#L38" style="text-decoration: none; color: rgb(12, 137, 207);"> 38</a>
<a target=_blank id="L39" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L39" rel="#L39" style="text-decoration: none; color: rgb(12, 137, 207);"> 39</a>
<a target=_blank id="L40" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L40" rel="#L40" style="text-decoration: none; color: rgb(12, 137, 207);"> 40</a>
<a target=_blank id="L41" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L41" rel="#L41" style="text-decoration: none; color: rgb(12, 137, 207);"> 41</a>
<a target=_blank id="L42" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L42" rel="#L42" style="text-decoration: none; color: rgb(12, 137, 207);"> 42</a>
<a target=_blank id="L43" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L43" rel="#L43" style="text-decoration: none; color: rgb(12, 137, 207);"> 43</a>
<a target=_blank id="L44" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L44" rel="#L44" style="text-decoration: none; color: rgb(12, 137, 207);"> 44</a>
<a target=_blank id="L45" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L45" rel="#L45" style="text-decoration: none; color: rgb(12, 137, 207);"> 45</a>
<a target=_blank id="L46" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L46" rel="#L46" style="text-decoration: none; color: rgb(12, 137, 207);"> 46</a>
<a target=_blank id="L47" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L47" rel="#L47" style="text-decoration: none; color: rgb(12, 137, 207);"> 47</a>
<a target=_blank id="L48" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L48" rel="#L48" style="text-decoration: none; color: rgb(12, 137, 207);"> 48</a>
<a target=_blank id="L49" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L49" rel="#L49" style="text-decoration: none; color: rgb(12, 137, 207);"> 49</a>
<a target=_blank id="L50" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L50" rel="#L50" style="text-decoration: none; color: rgb(12, 137, 207);"> 50</a>
<a target=_blank id="L51" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L51" rel="#L51" style="text-decoration: none; color: rgb(12, 137, 207);"> 51</a>
<a target=_blank id="L52" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L52" rel="#L52" style="text-decoration: none; color: rgb(12, 137, 207);"> 52</a>
<a target=_blank id="L53" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L53" rel="#L53" style="text-decoration: none; color: rgb(12, 137, 207);"> 53</a>
<a target=_blank id="L54" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L54" rel="#L54" style="text-decoration: none; color: rgb(12, 137, 207);"> 54</a>
<a target=_blank id="L55" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L55" rel="#L55" style="text-decoration: none; color: rgb(12, 137, 207);"> 55</a>
<a target=_blank id="L56" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L56" rel="#L56" style="text-decoration: none; color: rgb(12, 137, 207);"> 56</a>
<a target=_blank id="L57" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L57" rel="#L57" style="text-decoration: none; color: rgb(12, 137, 207);"> 57</a>
<a target=_blank id="L58" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L58" rel="#L58" style="text-decoration: none; color: rgb(12, 137, 207);"> 58</a>
<a target=_blank id="L59" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L59" rel="#L59" style="text-decoration: none; color: rgb(12, 137, 207);"> 59</a>
<a target=_blank id="L60" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L60" rel="#L60" style="text-decoration: none; color: rgb(12, 137, 207);"> 60</a>
<a target=_blank id="L61" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L61" rel="#L61" style="text-decoration: none; color: rgb(12, 137, 207);"> 61</a>
<a target=_blank id="L62" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L62" rel="#L62" style="text-decoration: none; color: rgb(12, 137, 207);"> 62</a>
<a target=_blank id="L63" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L63" rel="#L63" style="text-decoration: none; color: rgb(12, 137, 207);"> 63</a>
<a target=_blank id="L64" href="http://blog.csdn.net/nugongahou110/article/details/46780135#L64" rel="#L64" style="text-decoration: none; color: rgb(12, 137, 207);"> 64</a>
           
public class MainActivity extends Activity {
private Button btShare;
private Context mContext;
private Button btWeixin;
private Button btWeibo;
private Button btPengyouquan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = MainActivity.this;
btShare = (Button) findViewById(R.id.share);
btShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(mContext, R.style.Theme_Light_Dialog);
View dialogView = LayoutInflater.from(mContext).inflate(R.layout.my_dialog,null);
//获得dialog的window窗口
Window window = dialog.getWindow();
//设置dialog在屏幕底部
window.setGravity(Gravity.BOTTOM);
//设置dialog弹出时的动画效果,从屏幕底部向上弹出
window.setWindowAnimations(R.style.dialogStyle);
window.getDecorView().setPadding(0, 0, 0, 0);
//获得window窗口的属性
android.view.WindowManager.LayoutParams lp = window.getAttributes();
//设置窗口宽度为充满全屏
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
//设置窗口高度为包裹内容
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
//将设置好的属性set回去
window.setAttributes(lp);
//将自定义布局加载到dialog上
dialog.setContentView(dialogView);
btWeixin = (Button) dialogView.findViewById(R.id.bt_weixin);
btWeibo = (Button) dialogView.findViewById(R.id.bt_weibo);
btPengyouquan = (Button) dialogView.findViewById(R.id.bt_pengyouquan);
dialog.show();
btWeixin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext,"分享到微信",Toast.LENGTH_SHORT).show();
}
});
btWeibo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext,"分享到微博",Toast.LENGTH_SHORT).show();
}
});
btPengyouquan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext,"分享到朋友圈",Toast.LENGTH_SHORT).show();
}
});
}
});
}
}

来自CODE的代码片
MainActivity.java

Android实践-自定义dialog从屏幕底部弹出并且充满屏幕宽度相关推荐

  1. Android自定义dialog从屏幕底部弹出并且充满屏幕宽度

    效果如下 1.首先我们先来定义一个dialog的布局 <?xml version="1.0" encoding="utf-8"?> <Line ...

  2. Android开发中EditText获得焦点弹出输入框改变屏幕布局的问题

    在Android开发中,比较头疼的问题就是EditText总是已启动就获得焦点并弹出输入框,感觉很是不爽.而且,因为输入框的弹出,导致屏幕布局获得改变,有些空间被挤压到一起,很是难看,所以,我就上网搜 ...

  3. android 浮层菜单弹出,Android PopupWindow实现微信右上角的弹出菜单

    日常开发过程中对于PopupWindown的使用也是比较多的.这里给大家展示一下PopupWindow的使用. 修改activity_main.xml布局: xmlns:tools="htt ...

  4. Android监听系统输入法键盘弹出显示与隐藏事件

    Android监听系统输入法键盘弹出显示与隐藏事件 有时候需要监听Android系统输入法的弹出显示事件,比如:微信聊天时,不管你当前在聊天中的什么位置(上滑查看消息历史),每当你点击输入框时,都会自 ...

  5. android的自定义dialog样式,如何自定义Android Dialog的样式?

    如何自定义Android Dialog的样式?以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 如何自定义Android ...

  6. Android仿IOS封装通用的弹出框Dialog和底部弹出列表选择框 仿美团顶部条件筛选框 附自定义ViewGroup

    弹出框 背景 提示与询问弹出框 实现 使用 列表选择框 实现 使用 顶部条件筛选框 实现 自定义ViewGroup 使用 总结 背景 鉴于Android提供的默认弹出框很一般,IOS的弹出框样式还不错 ...

  7. Android的自定义键盘颜色,android自定义键盘(解决弹出提示的字体颜色问题)

    最近准备要做一个项目,需要用到自定义小键盘来确保安全,而且还需要精确获得用户点击键盘时的落点位置.力度.指尖接触屏幕的面积等参数. 在写自定义键盘的时 最近准备要做一个项目,需要用到自定义小键盘来确保 ...

  8. Android深入浅出系列之实例应用—弹出消息Toast对象的使用自定义方式(二)

    阅读目录 一:前言 二:实例 三:运行效果 一:前言 Android中定义了一个Toast对象,用以弹出一个窗口来给予用户帮助和提示,和对话框不同的是,Toast并不是以独占方式显示的,它并不会抢夺用 ...

  9. Android开发:利用Activity的Dialog风格完成弹出框设计

    转:http://www.linuxidc.com/Linux/2011-08/41933.htm 在我们使用Dialog时,如果需要用到很多自己设计的控件,虽然可以让弹出框显示出我们需要的界面,但却 ...

最新文章

  1. java实现上传_文件上传(java)
  2. 使用NetBeans 7.4 beta提示进行更好的基于JUnit的单元测试
  3. 前端学习(2962):前一天回顾
  4. 删除oracle怎么快,如何快速删除Oracle的好方法
  5. Perl连接Oracle数据库的一些操作脚本【转】
  6. Matlab之字符串的查找(findstr)与替换(strrep)
  7. python循环捕捉异常_python – 如何在for循环迭代器中捕获异常
  8. DTS音乐格式和常用播放软件及说明
  9. window 搜索占用进程 资源监视器
  10. Java高铁的速度是火车的两倍_超级高铁最高速度是飞机速度的近两倍,如果研发成功,对中国房价涨跌和中国高铁的比较优势会有什么影响?...
  11. 华为手机怎么修改dns服务器,华为域名解析修改dns
  12. 应用matlab快速实现实验对象随机分组,应用MATLAB快速实现实验对象随机分组
  13. 使用Inno Setup 制作软件安装包详细教程(与开发语言无关)
  14. 荣耀4a鸿蒙,华为荣耀4A上手评测:599元也可以很拉轰
  15. Web前端_配合swiper滑动插件实现同比例双指缩放图片
  16. 亚洲研究院微软笔试题
  17. Android应用程序如何进行系统签名
  18. Mismatch in datapacket 解决方法 (Delphi)
  19. 永磁同步电机(PMSM)最小损耗控制Simulink仿真
  20. 地平线 J3 智驾方案

热门文章

  1. 【机器学习项目实战】数据相关岗位薪资水平影响因素研究分析
  2. HRMS(人力资源管理系统)-SaaS架构设计-概要设计实践
  3. 如何提高小学生的课堂注意力?
  4. 百万级流量网站准备工作
  5. 实现网页全屏的5种方式
  6. PTA-求n以内最大的k个素数以及它们的和(C语言)
  7. idea注册码/不定期更新
  8. android 5寸屏分辨率是多少,索尼Z5的屏幕尺寸是多少?索尼Z5的分辨率是多少?...
  9. 去哪寻找创业合作伙伴
  10. Linux虚拟服务器-LVS-集群技术