安卓:中心图像 [英] Android: Center an image

查看:106
本文介绍了安卓:中心图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个线性布局和图像...

I've got a linear layout and an image...

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView android:layout_width="wrap_content" android:id="@+id/imageView1"
 android:src="@drawable/icon" android:layout_height="wrap_content"
 android:scaleType="center"></ImageView>

</LinearLayout>

如何动态地中心我的形象,这样它会出现在屏幕上的所有设备的中心?

How do I dynamically center my image so that it will appear in the center of the screen on all devices?

推荐答案

的LinearLayout ,使用安卓layout_gravity =中心

RelativeLayout的,使用机器人:layout_centerInParent =真正的

这篇关于安卓:中心图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆