アプリに画像プレビューを表示したい:ユーザーがリストビューのアイテムを押すと(各アイテムはSDカードに保存されている画像へのパスです)、この画像のように利用可能なスペースに引き伸ばされた画像プレビューが表示されます(画像スペース黒で、基になるアプリはまだ部分的に表示されていますが、灰色です):
ユーザーが戻るを押すと画像が消えます。画像表示だけの活動をしようと思ったのですが、写真で結果を出す方法がわかりません...
編集:
これが私がこれまでにしたことです:
1)マニフェスト:
<activity
android:name=".ImageDialogActivity" android:theme="@android:style/Theme.Dialog">
</activity>
2)レイアウト:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
3)アクティビティonCreateメソッド:
super.onCreate(savedInstanceState);
setContentView(R.layout.image_preview);
String filepath = getIntent().getStringExtra("image_filepath");
((ImageView)findViewById(R.id.imageView)).setImageBitmap(getBitmap(filepath));
ここで、getBitmapは、ファイルパスからビットマップを取得するプライベートメソッドです。
問題は、ダイアログのサイズを制御できないことです。ダイアログの幅と高さは、含まれている画像のサイズに依存しているようです...上/右/左/下の余白は言うまでもありません...
解決済み(多分):レイアウトファイルを次のように変更しました:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_height="200dp"
>>
<ImageView android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerInside"/>
効果を得るために許可された正方形に幅/高さを設定する...私の質問は:それはすべての電話で機能しますか?それとも私のものだけに適していますか?