【发布时间】:2014-02-14 23:57:23
【问题描述】:
我需要在图像下放置一些文本。使用我当前的代码,文本位于图像下方,但上边距相当大,并且偏离图像中心(向右移动约 10dp)。我想让我的文本直接位于图像下方,以图像为中心。
我尝试过android:layout_centerInParent="true",但这只会将我的文本放在屏幕中间。
这是我的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".ScanResults" >
<ImageView
android:id="@+id/productLogo"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/wedge_color"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
<TextView
android:id="@+id/productTitle"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_below="@id/productLogo"
android:gravity="center"
android:text="Fluffer Nutter Sandwich"
android:textSize="14sp" />
</RelativeLayout>
感谢您的帮助。
【问题讨论】:
标签: android textview imageview centering