Je crée une vue de liste pour le message de différentes hauteurs. Les vues sont des mises en page XML qui sont configurées pour mettre en page la même chose sur tous les écrans de résolution. Pour améliorer les performances, je convertis ces vues en images bitmap en appelant le View.getDrawingCache(). Je reçois l'image Bitmap, mais il semble s'agir de la mise à l'échelle du texte, en particulier dans les écrans haute résolution. Cela laisse le texte un peu flou et dans certains cas, il est également coupé sur les bords. Si je structure la vue plutôt que l'image bitmap, tout est mis à l'échelle correctement mais je ne reçois pas la performance que je désire. Mon mise en page élément XML ressemble à ceci:Android View.getDrawingCache bitmap incorrect
Xml Item Voir:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5px"
android:background="#FFFFFF">
<ImageView android:id="@+id/contact_photo"
android:layout_width="48dip"
android:layout_height="48dip"/>
<ImageView android:id="@+id/network_icon"
android:layout_alignParentRight="true"
android:layout_width="16dip"
android:layout_height="16dip"/>
<TextView android:id="@+id/created_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_toLeftOf="@+id/network_icon"
android:textColor="#000000"/>
<TextView android:id="@+id/sender_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_toRightOf="@+id/contact_photo"
android:ellipsize="end"
android:singleLine="true"
android:textColor="#000000"/>
<TextView android:id="@+id/summary"
android:layout_below="@+id/sender_name"
android:layout_toRightOf="@+id/contact_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:maxLines="4"
android:textColor="#000000" />
<LinearLayout
android:id="@+id/AttachmentLayout"
android:layout_below="@+id/summary"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_width="wrap_content"/>
</RelativeLayout>
Voir Mesure Snippet:
LayoutParams params = child.getLayoutParams();
if (params == null) {
params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}
final int index = layoutMode == LAYOUT_MODE_ABOVE ? 0 : -1;
child.setDrawingCacheEnabled(true);
addViewInLayout(child, index, params, true);
final int itemWidth = (int)(getWidth() * ITEM_WIDTH);
child.measure(MeasureSpec.EXACTLY | itemWidth, MeasureSpec.UNSPECIFIED);
J'ai également ajouté l'extrait de code préformage la mesure de la vue. Est-ce que quelqu'un sait comment empêcher la mise à l'échelle du texte?