我该如何放置图像在屏幕上的中心? [英] how i place image on center of screen?

查看:105
本文介绍了我该如何放置图像在屏幕上的中心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的code在屏幕上方森特如何放置图像在屏幕上的中心,地方形象?没有顶级中锋我的屏幕看起来像这个 http://imgur.com/65CD6

我想要的地方在屏幕上不运中心的中心

 <?XML版本=1.0编码=UTF-8&GT?;< RelativeLayout的机器人:ID =@ + ID / RelativeLayout01
的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_gravity =center_vertical | CENTER_HORIZONTAL
机器人:背景=#FFFFFF
机器人:layout_height =FILL_PARENT  机器人:layout_width =FILL_PARENT>
   < ImageView的机器人:ID =@ + ID / ImageView01
 机器人:SRC =@绘制/ agapplogo
 机器人:layout_width =WRAP_CONTENT 机器人:layout_marginLeft =60dip
机器人:layout_height =WRAP_CONTENT>
< / ImageView的>
< TextView的机器人:ID =@ + ID / TextView01
机器人:文字=@字符串/欢迎
机器人:layout_below =@ ID / ImageView01
机器人:layout_width =WRAP_CONTENT
  机器人:layout_height =WRAP_CONTENT>
 < / TextView的>
   < / RelativeLayout的>


&LT比重=中心

解决方案

您可以用玩安卓; RelativeLayout的>

包括的android:centerInParent =真正的里面的ImageView

this is my code which place image on top senter of screen how i place image on center of screen? not top center my screen look like this http://imgur.com/65CD6

i wanna place on center of screen not op center

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

<RelativeLayout android:id="@+id/RelativeLayout01" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_gravity="center_vertical|center_horizontal" 
android:background="#ffffff"
android:layout_height="fill_parent" 

  android:layout_width="fill_parent">


   <ImageView android:id="@+id/ImageView01" 
 android:src="@drawable/agapplogo" 
 android:layout_width="wrap_content"

 android:layout_marginLeft="60dip"
android:layout_height="wrap_content">
</ImageView>
<TextView android:id="@+id/TextView01" 
android:text="@string/welcome"
android:layout_below="@id/ImageView01" 
android:layout_width="wrap_content" 
  android:layout_height="wrap_content">
 </TextView>
   </RelativeLayout>

解决方案

You can either play with android:gravity="center" in <RelativeLayout>

OR

include android:centerInParent="true" inside ImageView

这篇关于我该如何放置图像在屏幕上的中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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