Android 将TextView与RelativeLayout内的ImageView底部对齐
我的布局如下:Android 将TextView与RelativeLayout内的ImageView底部对齐,android,android-layout,android-studio,Android,Android Layout,Android Studio,我的布局如下: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/miclubpyme_backgroundl" />
<TextView
android:id="@+id/txtStoreName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="I am a text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
我想让TextView与ImageView的底部对齐,但不在其外部。添加布局将使RelativeView占据屏幕的整个高度
下面是一幅图像,演示了这一点:
``
任何帮助都将不胜感激。
谢谢 您正在文本视图中查找的是
android:align\u bottom=“@+id/img”
,而不是android:align\u parentBottom=“true”
请在您的文本视图中尝试以下内容android:layou alignBottom
=“@id/img”`您必须将ImageView和TextView嵌套在与ImageView高度相同的视图组中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/miclubpyme_backgroundl" />
<TextView
android:id="@+id/txtStoreName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="I am a text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</FrameLayout>
</RelativeLayout>
哪个部分是图像,哪个部分不是?看起来还有另一部分占据了图像和设备布局底部之间的空间不,我试过了,但它对我不起作用。谢谢。不,我试过了,但对我不起作用。谢谢你。