0
我有一項活動使用android:theme="@android:style/Theme.Dialog"
。該活動包含一個ImageView,可以顯示不同尺寸的圖像。 ImageView應縮放圖像,使其完全適合窗口,至少在軸上完全適合並保持原始高寬比。對話框的大小隻能和ImageView一樣大(加上它的邊框寬度)。如何在對話式活動中將圖像縮放到最大尺寸
我嘗試以下,但對話窗口始終使用整個可用空間:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip">
<ProgressBar
android:id="@android:id/progress"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_centerInParent="true"
android:visibility="gone"
style="@android:attr/progressBarStyleSmallTitle"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:id="@+id/image"/>
</RelativeLayout>