2012-02-29 53 views
2

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

现在仪式,我有这个

enter image description here

什么,我想要实现

enter image description here

这样不仅形象,而且即使我试图做一个正常大小

这里的QuickContactBadge是我的代码,我使用

Uri contactUri = Uri.withAppendedPath(
          ContactsContract.Contacts.CONTENT_URI, 
          String.valueOf(contactId)); 

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


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

我的布局列表项

<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" /> 
+1

//努力代码的Android:layout_height =“50dp “android:layout_width =”50dp“ – 2012-02-29 12:10:56

+0

@PadmaKumar你的评论作品,你也可以回答它 – Hunt 2012-03-05 09:12:33

回答

2

//尝试硬编码你的版面高度和宽度

android:layout_height= "50dp" android:layout_width= "50dp" 

//确保使用DP/DIP这个充满适合所有的屏幕分辨率

假设您的MDPI 50dp将是相同的50像素

mdpi 50*160/160=50px 
hdpi 50*240/160=75px 
xhdpi 50*320/160=100px