为什么有差距时,我alignTop? [英] Why is there a gap when I alignTop?
本文介绍了为什么有差距时,我alignTop?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么有文本的顶部和图像??
的顶部之间的空间 <?XML版本=1.0编码=UTF-8&GT?;<的LinearLayout 的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_margin =9dp
机器人:背景=#FFF>
< RelativeLayout的 机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_margin =9dp>
< ImageView的
机器人:ID =@ + ID / img_user
机器人:layout_width =30dp
机器人:layout_height =30dp
机器人:layout_marginRight =9dp
机器人:背景=#000/> <的TextView
机器人:ID =@ + ID /用户名
机器人:layout_toRightOf =@ ID / img_user
机器人:layout_alignTop =@ ID / img_user
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#333
机器人:文字样式=大胆
机器人:TEXTSIZE =12dp
机器人:重力=顶
机器人:文字=用户名/>
<的TextView
机器人:ID =@ + ID /时间戳
机器人:layout_toRightOf =@ ID / img_user
机器人:layout_alignBottom =@ ID / img_user
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#999
机器人:TEXTSIZE =10dp
机器人:重力=底
机器人:文字=2H/>
< / RelativeLayout的>
解决方案
这是TextView中固有的一部分。尝试使用空间,并考虑周围包裹额外的布局给你房间搬东西。
Why is there space between the top of the text and the top of the image??
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="9dp"
android:background="#FFF">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="9dp">
<ImageView
android:id="@+id/img_user"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="9dp"
android:background="#000" />
<TextView
android:id="@+id/username"
android:layout_toRightOf="@id/img_user"
android:layout_alignTop="@id/img_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:textStyle="bold"
android:textSize="12dp"
android:gravity="top"
android:text="Username" />
<TextView
android:id="@+id/timestamp"
android:layout_toRightOf="@id/img_user"
android:layout_alignBottom="@id/img_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999"
android:textSize="10dp"
android:gravity="bottom"
android:text="2h"/>
</RelativeLayout>
解决方案
This is an inherent part of TextView. Try using margins, and consider wrapping extra layouts around to give you room to move things.
这篇关于为什么有差距时,我alignTop?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文