dialog全屏显示图片
来源:互联网 发布:虚拟机装mac蓝屏 编辑:程序博客网 时间:2024/06/05 19:19
主题<style name="quick_option_dialog" parent="@style/Theme.AppCompat.Dialog"> <item name="android:windowBackground">@color/white</item></style>public class CustomDialog extends Dialog { public CustomDialog(Context context,String path) { //重写dialog默认的主题 this(context, R.style.quick_option_dialog,path); } public CustomDialog(Context context, int themeResId,String path) { super(context, themeResId); View convertView = getLayoutInflater().inflate(R.layout.dialog_photo_entry, null); requestWindowFeature(Window.FEATURE_NO_TITLE); ImageView img = (ImageView) convertView.findViewById(R.id.large_image); img.setImageDrawable(stringToDrawable(path)); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); setContentView(convertView); } @Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); getWindow().setGravity(Gravity.BOTTOM); //显示在底部 WindowManager m = getWindow().getWindowManager(); Display d = m.getDefaultDisplay(); WindowManager.LayoutParams p = getWindow().getAttributes(); p.width = d.getWidth(); //设置dialog的宽度为当前手机屏幕的宽度 getWindow().setAttributes(p); } /** * 本地图片转为drawable方法 * * @param path * @return */ public static Drawable stringToDrawable(String path) { FileInputStream input = null; try { input = new FileInputStream(new File(path)); } catch (FileNotFoundException e) { e.printStackTrace(); } // 先转换成bitmap Bitmap bmp = BitmapFactory.decodeStream(input); // 再转换成drawable @SuppressWarnings("deprecation") Drawable drawable = new BitmapDrawable(bmp); return drawable; }}
0 0
- dialog全屏显示图片
- Android dialog全屏显示
- Dialog全屏显示
- 设置Dialog全屏显示
- Dialog 全屏显示
- 全屏显示Dialog的设置
- 全屏显示Dialog的设置
- 关于Android Dialog全屏显示
- 设置Dialog全屏显示(转)
- GridView显示本地图片后,点击全屏查看,使用dialog显示
- 全屏显示网页背景图片
- ImageView图片全屏显示
- 图片全屏显示
- html5全屏显示图片
- 【android】自定义全屏dialog显示+listview
- android 超简单实现dialog全屏显示
- android 设置自定义dialog全屏显示
- Android Dialog显示成Activity(全屏)
- Sping(6)SSH开发
- ubuntu安装PHP+nginx+mongoDB
- Linux配置Tomcat
- 语言的碰撞
- Default Constructor
- dialog全屏显示图片
- Gflag使用
- python 3计算KL散度(KL Divergence)
- 配置tomcat连接池
- QList
- Android页面跳转详解
- WPF RichTextBox 插入换行 移动光标
- 为Tomcat分配内存
- Windows Live Writer使用代码高亮工具