Java 相对布局如何与其他元素而不是父元素对齐
我有一个相对布局,我已经对齐了几乎所有我想要的元素,但在右下角有两个元素(textView和禁止照片的图标),它们与父元素对齐,父元素不是照片 我想将这些元素与我拥有的图像底部对齐: 这是一个 预期成果: 矩形是我想要文本视图和相机禁止图标的地方 下面是xml:Java 相对布局如何与其他元素而不是父元素对齐,java,android,xml,android-layout,Java,Android,Xml,Android Layout,我有一个相对布局,我已经对齐了几乎所有我想要的元素,但在右下角有两个元素(textView和禁止照片的图标),它们与父元素对齐,父元素不是照片 我想将这些元素与我拥有的图像底部对齐: 这是一个 预期成果: 矩形是我想要文本视图和相机禁止图标的地方 下面是xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.androi
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="142dp"
android:layout_gravity="center"
android:layout_margin="@dimen/card_margin"
android:elevation="3dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
card_view:cardCornerRadius="@dimen/card_specie_radius">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="@+id/Avaliation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/plantName"
android:layout_marginStart="92dp"
android:layout_marginTop="15dp"
android:text="Avalie a fotografia" />
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/plantPhoto"
android:textColor="@color/base"
android:layout_marginTop="4dp"
android:layout_toStartOf="@+id/cameraForbiden"
android:text="TextView" />
<ImageView
android:id="@+id/reportImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/color_cursor_white" />
<ImageView
android:id="@+id/plantPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp" />
<ImageView
android:id="@+id/userIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentBottom="true"
android:layout_below="@id/plantPhoto"
android:src="@drawable/ic_user"
/>
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="@+id/plantName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/plantPhoto"
android:textColor="@color/nephritis"
android:textSize="18sp" />
<ImageView
android:id="@+id/starIcon"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/plantName"
android:src="@drawable/ic_star"
android:layout_marginLeft="10dp"
/>
<ImageView
android:id="@+id/cameraForbiden"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_toRightOf="@+id/plantName"
android:layout_marginLeft="10dp"
android:src="@drawable/ic_no_photos"
android:layout_below="@id/plantPhoto"
/>
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/plantPhoto"
android:textColor="@color/base"
android:layout_marginEnd="29dp"
android:layout_marginTop="8dp"
android:layout_toEndOf="@+id/userIcon"
android:layout_toLeftOf="@+id/userIcon"
android:paddingLeft="10px"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
使用以下代码:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/plantPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_margin="5dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/userIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@drawable/ic_user"
/>
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="@+id/plantName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/nephritis"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
请张贴一张预期结果的图片!不要使用layout\u alignParentBottom
使用layout\u alignBottom