Android 如何将imageview安装在可绘图的底部

Android 如何将imageview安装在可绘图的底部,android,Android,我想知道如何将底部img放置在直线的中心。我该怎么做?我希望+图标位于矩形边框的中心 这是recycler视图和imageview的布局代码 <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <FrameLayout android:id="@+

我想知道如何将底部img放置在直线的中心。我该怎么做?我希望+图标位于矩形边框的中心

这是recycler视图和imageview的布局代码

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <FrameLayout
                android:id="@+id/skillsLL"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/_15"
                android:layout_marginTop="@dimen/_10"
                android:layout_marginEnd="@dimen/_15"
                android:layout_marginBottom="@dimen/_15"
                android:orientation="vertical">


                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/skillsRV"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/education_outline"
                    android:paddingStart="@dimen/_15"
                    android:paddingEnd="@dimen/_15"
                    android:visibility="visible"

app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
                    app:spanCount="3" />

                <ImageView
                    android:id="@+id/addIMG"
                    android:layout_width="@dimen/_15"
                    android:layout_height="@dimen/_15"
                    android:layout_alignParentBottom="true"
                    android:layout_centerInParent="true"
                    android:layout_gravity="bottom|center"
                    android:adjustViewBounds="true"
                    android:scaleType="fitEnd"
                    android:src="@drawable/ic_more" />

            </FrameLayout>


        </RelativeLayout>

这是我放在后面的可绘制代码

 <?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android">
 <solid android:color="@color/background_color"/>
 <corners android:radius="15dp" />
 <stroke android:width="0.5dp" android:color="@color/black" />
 </shape>

我会这么做。您不需要使用此方法将
框架布局
更改为
约束布局

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <FrameLayout
                android:id="@+id/skillsLL"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/_15"
                android:layout_marginTop="@dimen/_10"
                android:layout_marginEnd="@dimen/_15"
                android:layout_marginBottom="@dimen/_15"
                android:orientation="vertical">

            // Keep everything else as it is . . .

            </FrameLayout>

                <ImageView
                    android:id="@+id/addIMG"
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_below="@id/skillsLL"
                    android:adjustViewBounds="true"
                    android:scaleType="fitEnd"
                    android:src="@drawable/ic_more"
                    android:layout_marginTop="-10sp" />

        </RelativeLayout>

//其他一切保持原样。
将图像视图带出框架布局,然后尝试我的代码。确保像我使用的一样使用维度。您可以稍后调整它们


基本上,你是把图像放在框架布局下面,然后把图像移到上面一半的高度。。如果您在评论中需要更多帮助,请告诉我

最好的方法是
ConstraintLayout
没有任何负边距。只需使用下面的布局即可。。它适用于所有屏幕尺寸

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/skillsRV"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="visible"
            app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:spanCount="3" />

    <ImageView
            android:id="@+id/imageView"
            android:layout_width="20dp"
            android:layout_height="20dp"
            app:layout_constraintBottom_toBottomOf="@+id/skillsRV"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/skillsRV"
            app:srcCompat="@drawable/ic_more" />

</androidx.constraintlayout.widget.ConstraintLayout>

我已经为我的一个屏幕实现了这个功能。你可以试试这个

<RelativeLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


                <android.support.constraint.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_marginStart="@dimen/_15sdp"
                    android:layout_marginTop="@dimen/_10sdp"
                    android:layout_marginEnd="@dimen/_15sdp"
                    android:layout_marginBottom="@dimen/_15sdp"
                    android:layout_height="wrap_content">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/skillsRV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/base_bg_rectangle"
                        android:paddingStart="@dimen/_15sdp"
                        android:paddingEnd="@dimen/_15sdp"
                        android:visibility="visible"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        android:layout_marginBottom="@dimen/_7sdp"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layoutManager="android.support.v7.widget.GridLayoutManager"
                        app:spanCount="3" />

                    <ImageView
                        android:id="@+id/addIMG"
                        android:layout_width="@dimen/_15sdp"
                        android:layout_height="@dimen/_15sdp"
                        android:layout_centerInParent="true"
                        android:layout_gravity="bottom|center"
                        android:adjustViewBounds="true"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        android:scaleType="fitEnd"
                        android:src="@drawable/default_image" />
                </android.support.constraint.ConstraintLayout>


    </RelativeLayout>

使用ConstraintLayout而不是FrameLayout,然后将图像视图的上下约束约束到回收器视图的底部

将imageview的侧面约束为RecyclerView的侧面

ImageView的代码:

<ImageView
        android:id="@+id/addIMG"
        android:layout_width="15dp"
        android:layout_height="15dp"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:layout_gravity="bottom|center"
        android:adjustViewBounds="true"
        android:scaleType="fitEnd"
        android:src="@drawable/refresh"
        app:layout_constraintBottom_toBottomOf="@+id/skillsRV"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/skillsRV" />


也添加布局代码。
@dimen/_15
的价值是什么?@Dharmaraj其15dp检查我的代码..我在哪里可以安装recyclerview?@AhsanAbdullah保留其余代码。带上我的图像代码。将图像从框架布局移到外部相对布局