调整AlertDialog恰好适合图​​像 [英] Resize AlertDialog to fit image exactly

查看:188
本文介绍了调整AlertDialog恰好适合图​​像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下AlertDialog,内带一个图像:

正如你可以看到有一个小的差距正上方,只是下面的图片。我想删除这个空白。

我的布局XML是这样的:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
              机器人:ID =@ + ID / alert_thumb_root
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT>  < ImageView的机器人:ID =@ + ID /拇指
             机器人:layout_width =WRAP_CONTENT
             机器人:layout_height =WRAP_CONTENT/>
< / LinearLayout中>


解决方案

除非您通过你的自我整个对话,这真的很难控制这种事情。但是,如果你不介意调整图像大小,你可以尝试这样的:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
              机器人:ID =@ + ID / alert_thumb_root
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT>  < ImageView的机器人:ID =@ + ID /拇指
             机器人:layout_width =WRAP_CONTENT
             机器人:layout_height =WRAP_CONTENT
             机器人:scaleType =fitXY/>
< / LinearLayout中>

I have the following AlertDialog with an image inside it:

As you can see there is a small gap just above and just below the image. I'd like to remove that gap.

My layout xml looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/alert_thumb_root"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" >

  <ImageView android:id="@+id/thumb"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content" />
</LinearLayout>

解决方案

Unless you create the whole dialog by your self, it's really difficult to control those kind of things. However, if you don't mind resizing the image, you could try something like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/alert_thumb_root"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" >

  <ImageView android:id="@+id/thumb"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:scaleType="fitXY"/>
</LinearLayout>

这篇关于调整AlertDialog恰好适合图​​像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆