[英]image are showing in too small in android nexus phone
我創建了一個項目以輪播視圖的形式顯示圖像。當我在許多設備中運行該項目時。 在連結電話中測試時,圖像尺寸顯示過小。 這是我項目中的大問題。 請告訴我解決這個問題的方法...
謝謝
我沒有將圖像的副本放置為mdpi,hdpi,xhdpi等,因為這種方法的圖像太多,而且apk太大。 (順便說一下,只有非常老的電話才使用ldpi)。
取而代之的是,我將所有圖像都以mdpi放置並放大為平板電腦(例如,類似以下內容):
if (isTablet(getActivity())){ // tablets only
debugLog( "display tablet image="+imagename);
int resID = getResources().getIdentifier(imagename,"drawable", getActivity().getPackageName()); // the corresponding resource id
if (resID != 0) {
Bitmap bmp=BitmapFactory.decodeResource(getResources(), resID);
int width=480;
int height=300;
Bitmap resizedbitmap=Bitmap.createScaledBitmap(bmp, width, height, true);
ImageView imageView = (ImageView) getActivity().findViewById(R.id.tablet_image); // the imageview to change
//imageView.setImageResource(resID);
imageView.setImageBitmap(resizedbitmap);
}
}
使用不同的調光器。
在不同的設備中定義了不同的調光。
值值-ldpi值-mdpi值-hdpi值-xhdpi值-nodpi值-nodpi-1024×600值-nodpi-1280×800值-nodpi-800×480
等等..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.