在图像视图中以全尺寸显示位图
Displaying a bitmap to full size in imageview
我正在尝试将从外部卡加载的位图显示到占据整个屏幕的图像视图。我的目标是展示它在 Gallery 应用程序中的显示方式。我尝试在布局 xml 中使用 scaletype="center"
、scaletype="fitXY"
和 adjustViewBounds="true"
。
我的xml是这样的
<ImageView
android:layout_width="wrap_content"
android:adjustViewBounds="false"
android:scaleType="center"
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:id="@+id/player_imageview" />
例如,
这就是我的图库应用程序显示它的方式
这是我的应用程序显示它的方式
如有任何帮助,我们将不胜感激。谢谢。
请试试这个。
<ImageView
android:layout_width="wrap_content"
android:adjustViewBounds="false"
android:scaleType="fitCenter"
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:id="@+id/player_imageview" />
我自己想出了问题的答案。我浏览了 android Gallery 应用程序的源代码。 Link to the layout of Gallery app。他们将自定义图像视图嵌入到 AbsoluteLayout 中。由于不推荐使用 AbsoluteLayout,我将我的 Imageview 嵌入到 FrameLayout 中。
解决方法是
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/player_imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF000000" />
</FrameLayout>
此 FrameLayout 位于 RelativeLayout 内。至此,固定。谢谢。 :)
我正在尝试将从外部卡加载的位图显示到占据整个屏幕的图像视图。我的目标是展示它在 Gallery 应用程序中的显示方式。我尝试在布局 xml 中使用 scaletype="center"
、scaletype="fitXY"
和 adjustViewBounds="true"
。
我的xml是这样的
<ImageView
android:layout_width="wrap_content"
android:adjustViewBounds="false"
android:scaleType="center"
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:id="@+id/player_imageview" />
例如,
这就是我的图库应用程序显示它的方式
这是我的应用程序显示它的方式
如有任何帮助,我们将不胜感激。谢谢。
请试试这个。
<ImageView
android:layout_width="wrap_content"
android:adjustViewBounds="false"
android:scaleType="fitCenter"
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:id="@+id/player_imageview" />
我自己想出了问题的答案。我浏览了 android Gallery 应用程序的源代码。 Link to the layout of Gallery app。他们将自定义图像视图嵌入到 AbsoluteLayout 中。由于不推荐使用 AbsoluteLayout,我将我的 Imageview 嵌入到 FrameLayout 中。
解决方法是
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/player_imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF000000" />
</FrameLayout>
此 FrameLayout 位于 RelativeLayout 内。至此,固定。谢谢。 :)