2

仿QQ的头像选择弹出的对话框

 3 years ago
source link: http://www.androidchina.net/782.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
仿QQ的头像选择弹出的对话框 – Android开发中文站

这个例子是点击按钮后,选择菜单会从屏幕底部慢慢弹出来,按菜单以外的屏幕,菜单会消失。

先看一下效果吧。

对话框布局xml文件如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:gravity="bottom"
android:orientation="vertical"
android:padding="5dip" >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/photo_gallery_selector"
android:paddingBottom="10dip"
android:paddingTop="10dip"
android:text="图库"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dip"
android:background="#DAD9DB" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/photo_camera_selector"
android:paddingBottom="10dip"
android:paddingTop="10dip"
android:text="拍照"
android:textSize="16sp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:background="@drawable/photo_cancel_selector"
android:paddingBottom="10dip"
android:paddingTop="10dip"
android:text="取消"
android:textSize="16sp" />
</LinearLayout>

为了实现动画效果,还需要定义两个动画文件

<translate
android:duration="500"
android:fromXDelta="0"
android:fromYDelta="1000"
android:toXDelta="0"
android:toYDelta="0" />
</set>

其中:
translate 位置转移动画效果
整型值:

  • fromXDelta 属性为动画起始时 X坐标上的位置
  • toXDelta 属性为动画结束时 X坐标上的位置
  • fromYDelta 属性为动画起始时 Y坐标上的位置
  • toYDelta 属性为动画结束时 Y坐标上的位置

注意:
没有指定, 默认是以自己为相对参照物
长整型值:
duration 属性为动画持续时间
说明: 时间以毫秒为单位
在这些属性里面还可以加上%和p,例如:

  • android:toXDelta=”100%”,表示自身的100%,也就是从View自己的位置开始。
  • android:toXDelta=”80%p”,表示父层View的80%,是以它父层View为参照的。

源码下载:点击下载

转载请注明:Android开发中文站 » 仿QQ的头像选择弹出的对话框


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK