2012-01-20 15 views
1

私はイメージ(320x210)を持っていますが、私はxmlファイルのdrawableフォルダからイメージを呼び出します...ポートレートモードでは問題なく動作しますが、デバイスをLANDSCAPEに変更している間は、その問題を解決する方法.. ?? は、ここで私は方向変更の画像のサイズを変更する方法..?

<ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:scaleType="fitCenter"(here i tried with "fitXY" also) 
     android:adjustViewBounds="true" 
     android:src="@drawable/srkpic"/> 

を試しても、私はこの方法 保護空隙と試みonSizeChanged私のXMLコードである(INT、W INT H、INT oldW、INT oldH) { } しかし、この方法は、利用可能です私が私の要件を満たしていない "ビュー"で拡張する場合。おかげさまで

答えて

2

はimgHeaderFooterは、私がしようとしたそのworking..butアプリは、私がいけないrestarting..thatであるあなたのビットマップ

imgHeaderFooter.setDensity(1/2); 

     int width = imgHeaderFooter.getWidth(); 
     int height = imgHeaderFooter.getHeight(); 

     int screenWidth = UseMe.getDispWidth()/2; 

     float scaleWidth = ((float) screenWidth)/width; 
     float scaleHeight = ((float) height)/height;  

     Matrix matrix = new Matrix(); 
     matrix.postScale(scaleWidth,scaleHeight); 
     Bitmap resizedBitmap = Bitmap.createBitmap(imgHeaderFooter,0,0,width,height,matrix,true); 
     BitmapDrawable bmd = new BitmapDrawable(resizedBitmap); 

     imageView = new ImageView(this); 
     imageView.setScaleType(ScaleType.FIT_XY); 
     imageView.setImageDrawable(bmd); 
+0

これは何ですか... UseMe int screenWidth = UseMe.getDispWidth()/ 2; – KKC

+0

UseMe.getDispWidth()/ 2は、実際にアンドロイドデバイスの画面幅を2で割ったもので、WindowManager w = getWindowManager()です。 \t \t表示d = w.getDefaultDisplay(); \t \t int width = d.getWidth()/ 2; \t \t int height = d.getHeight()/ 2; – amandroid

+0

こんにちは、arun私はあなたが言ったようにしてみましたが、動作していない、私は同じ問題を抱えています。イメージはreSizeではありません....私はそのコードonConfigurationChanged(構成confi)メソッドを書いています。 – KKC

2

風景用にサイズ変更された代替リソースをres/drawable-land(srkpic)に指定します。

+0

ya..thatであるあなたの向きの変更に以下のコードを使用します。それ以外の他の方法..それ??? – KKC

+0

アクティビティのandroid:configChange属性をチェックする必要があります。 –

関連する問題