android:如何在imageview的水平中心对齐图像?

标签 android alignment

我尝试了所有比例类型,但所有这些都会导致图像位于 ImageView 的左角。

 <ImageView
    android:id="@+id/image"
    android:scaleType="centerInside"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:layout_marginRight="6dip"
    android:background="#0000" 
    android:src="@drawable/icon1" />

最佳答案

<ImageView
    android:id="@+id/img"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" />

关于android:如何在imageview的水平中心对齐图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2587305/

相关文章:

没有子类化的Android xml全局自定义标签

java - 如何测试绘制到 Canvas 的方法?

html - 使用 HTML 和 CSS,如何使图像与水平线垂直对齐?

c# - 如何在 XAML 中将多个 StatusBarItems 对齐到右侧?

Javascript Div 最高

java - Android tabhost 问题...包含代码

android - GLSurfaceView onDrawFrame 清除行为

android - 使用可跨越字符串更改阿拉伯语变音符号颜色在某些手机上不起作用

CSS:对齐 float li 在 div 内居中?

HTML 输入元素被父容器剪裁