首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >图像不适合QuickContactBadge

图像不适合QuickContactBadge
EN

Stack Overflow用户
提问于 2012-02-29 20:03:01
回答 1查看 891关注 0票数 2

我已经创建了一个联系电话的列表视图,列表项包含的QuickContactBadgeTextView现在每当我试图加载图像到QuickContactBadge它does not get fit into的QuickContactBadge框架,同时QuickBadgeContact itself will also get shrink.

现在我有了这个

我想要实现的是

因此,不仅是图像,甚至我也在尝试制作正常大小的QuickContactBadge

下面是我正在使用的代码

代码语言:javascript
复制
    Uri contactUri = Uri.withAppendedPath(
                            ContactsContract.Contacts.CONTENT_URI, 
                             String.valueOf(contactId));

    InputStream input = ContactsContract.Contacts.openContactPhotoInputStream
                            (
                            getContentResolver(), contactUri
                            );


 cache.photoView.setImageBitmap(BitmapFactory.decodeStream(input));

我的列表项布局

代码语言:javascript
复制
<QuickContactBadge
        android:id="@+id/badge"
        android:layout_marginLeft="2dip"
        android:layout_marginRight="14dip"
        android:layout_marginTop="4dip"
        android:layout_marginBottom="3dip"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_height= "wrap_content"
        android:layout_width= "wrap_content"
        android:src="@drawable/ic_contact_picture"
        style="?android:attr/quickContactBadgeStyleWindowSmall" />

    <TextView
        android:id="@+id/name"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:paddingLeft="2dip"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/badge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-05 17:19:37

//尝试对布局高度和宽度进行硬编码

代码语言:javascript
复制
android:layout_height= "50dp" android:layout_width= "50dp"

//确保使用dp/dip此填充适合您的所有屏幕分辨率

假设mdpi的50dp将与50px相同

代码语言:javascript
复制
mdpi 50*160/160=50px
hdpi 50*240/160=75px
xhdpi 50*320/160=100px
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9498809

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档