Android效果:FrameLayout实现中间头像的Dialog
2017-03-01 15:54
411 查看
1.Dialog布局
2.AS预览图
![](https://img-blog.csdn.net/20170301155027277?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbHVzaGFuMTk5MA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
3.java代码
4.实现的效果图
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_35" android:background="@color/white" android:gravity="center_horizontal" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_50" android:gravity="center_horizontal" android:orientation="horizontal"> <TextView android:id="@+id/txt_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="冒险样" android:textColor="@color/text_color_normal" android:textSize="@dimen/font_size_25sp" /> <ImageView android:id="@+id/img_statue" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> <TextView android:id="@+id/txt_phone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_10" android:text="13410268689" android:textColor="@color/text_color_normal" android:textSize="@dimen/font_size_16sp" /> <Button android:id="@+id/btn_say_hello" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/dp_20" android:layout_marginRight="@dimen/dp_20" android:background="@drawable/logout" android:layout_marginTop="@dimen/dp_20" android:layout_marginBottom="@dimen/dp_20" android:text="即可打招呼 获见面大礼" android:textColor="@color/white" android:textSize="@dimen/font_size_20sp" /> </LinearLayout> <com.meitianhui.convenitenbuy.widget.CircleImageView android:id="@+id/imgHead" android:layout_width="@dimen/dp_70" android:layout_height="@dimen/dp_70" android:layout_gravity="top|center_horizontal" android:src="@drawable/commfra_img_jx" /> </FrameLayout>
2.AS预览图
3.java代码
public class SayHelloDialog extends Dialog { private Context mContext; private Activity mActivity; private SayHelloClickListener listener; private CircleImageView imgHead;// private TextView txt_name;// private ImageView img_statue;//等级 private TextView txt_phone;//电话 private Button btn_say_hello;//跳转 public SayHelloDialog(Context context, SayHelloClickListener l) { super(context); this.mContext = context; } public SayHelloDialog(Activity context, int themeResId, SayHelloClickListener l) { super(context, themeResId); mContext = context; mActivity = context; this.listener = l; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_say_hello); DisplayMetrics metric = new DisplayMetrics(); mActivity.getWindowManager().getDefaultDisplay().getMetrics(metric); WindowManager.LayoutParams p = getWindow().getAttributes(); p.width = (int) (metric.widthPixels - 100); Window window = getWindow(); window.setAttributes(p); window.setGravity(Gravity.CENTER); setCancelable(true); this.setCanceledOnTouchOutside(true); imgHead = (CircleImageView)findViewById(R.id.imgHead); txt_name = (TextView)findViewById(R.id.txt_name); txt_phone = (TextView)findViewById(R.id.txt_phone); img_statue = (ImageView) findViewById(R.id.img_statue); btn_say_hello = (Button) findViewById(R.id.btn_say_hello); btn_say_hello.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { listener.sayHello(); dismiss(); } }); } public interface SayHelloClickListener { public void sayHello(); } }
4.实现的效果图
相关文章推荐
- android 头像组合效果实现
- android自定义dialog实现下拉弹出框效果
- AndroidUI之三分钟教你实现效果简单大气的Dialog提示框
- Android 中从屏幕左下角弹出Dialog动画效果的实现代码
- Android利用CircleImageView实现圆形头像效果
- Android实现弹出输入法时,顶部固定,中间部分上移的效果
- Android实现仿有道云笔记头像背景(模糊效果)
- Android UI设计系列之自定义Dialog实现各种风格的对话框效果(7)
- android实现类似toast效果的圆角dialog警告框
- Android实现自定义AlertDialog的自下向上的动画效果(并消除dialog边框)
- 【Android】使用FrameLayout布局实现霓虹灯效果
- Android开发—利用FrameLayout实现图标中间显示文字
- Android UI设计之<七>自定义Dialog,实现各种风格效果的对话框
- android实现中间卡位下方viewpager效果展示
- Android 实现 按钮从两边移到中间动画效果
- 【Android】使用FrameLayout布局实现霓虹灯效果
- android脚步---使用framelayout实现霓虹灯效果
- Android实现弹出输入法时,顶部固定,中间部分上移的效果
- android dialog实现底部弹出和手指滑动隐藏效果
- Android自定义Dialog实现文字动态加载效果