Android效果:FrameLayout实现中间头像的Dialog
来源:互联网 发布:橙光游戏制作软件mac 编辑:程序博客网 时间:2024/06/15 13:50
1.Dialog布局
<?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.实现的效果图
0 0
- Android效果:FrameLayout实现中间头像的Dialog
- 【Android】使用FrameLayout布局实现霓虹灯效果
- android 头像组合效果实现
- Android的dialog和实现点击效果
- Android利用CircleImageView实现圆形头像效果
- android学习笔记6:使用Framelayout实现霓虹灯效果
- 使用FrameLayout实现霓虹灯效果
- 继承framelayout,实现ScrollView 和 HorizontalScrollView 的效果
- 实现圆形头像效果
- 【Android】更换头像的实现
- android上dialog横屏下实现全屏效果
- Android自定义Dialog实现弹出二维码效果
- Android实现仿有道云笔记头像背景(模糊效果)
- Android利用CircleImageView实现圆形头像效果整理
- Android 使用PullToZoomScrollViewEx实现头像下拉缩放动态效果
- Android实现弹出输入法时,顶部固定,中间部分上移的效果
- Android实现弹出输入法时,顶部固定,中间部分上移的效果
- Android实现弹出输入法时,顶部固定,中间部分上移的效果
- 基础理论知识复习(上)
- 【webpack】-- 自动刷新
- Notification基础详解三(宽视图布局通知)
- ES6中的Generator函数
- Nvidia + Ubuntu/Win7
- Android效果:FrameLayout实现中间头像的Dialog
- Linux常用命令
- IPC机制--利用ContentProvider
- C#FTP类
- Android走进源码告诉你app是如何被启动的
- (M)SIM卡开机流程分析之TelephonyDevController类分析
- MTK 冻屏问题分析
- 前沿
- caffe的Matlab接口问题之路径问题