-1

How to add a circular image on Image view as the below image:

example

and this is the code I have:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    xmlns:card_view="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_margin="3dp"
        card_view:cardBackgroundColor="@color/colorwhite"
        card_view:cardCornerRadius="8dp"
        card_view:cardUseCompatPadding="false"
        card_view:elevation="15dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="130dp"
            android:layout_gravity="center_horizontal"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/flag"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:scaleType="fitXY"
                android:src="@drawable/mac_img" />

            <TextView
                android:id="@+id/titleTxt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_marginTop="85dp"
                android:textStyle="bold"
                android:textColor="@color/colorwhite"
                android:layout_centerHorizontal="true" />


        </RelativeLayout>


    </androidx.cardview.widget.CardView>

</LinearLayout>

as I am trying also add the a text view like is shown in the image like the Closed, So all I need I want the way to do this as to put widgets like this way as in the figure..

Mahmoud Al-Haroon
  • 2,239
  • 7
  • 36
  • 72

1 Answers1

0

Ok good I solved it by adding some margins I hope someone give me a recommendation about this, and this is the full code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_margin="3dp"
        card_view:cardBackgroundColor="@color/colorwhite"
        card_view:cardCornerRadius="8dp"
        card_view:cardUseCompatPadding="false"
        card_view:elevation="15dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="130dp"
            android:layout_gravity="center_horizontal"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/flag"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:scaleType="fitXY"
                android:src="@drawable/mac_img" />

            <TextView
                android:id="@+id/titleTxt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_marginTop="85dp"
                android:textStyle="bold"
                android:textColor="@color/colorwhite"
                android:layout_centerHorizontal="true" />


        </RelativeLayout>

        <com.cuboid.cuboidcirclebutton.CuboidButton
            android:layout_width="70dp"
            android:layout_height="70dp"
            app:cub_border_color="@color/color_64b5f6"
            app:cub_border_radius="4dp"
            android:layout_marginTop="85dp"
            android:layout_marginLeft="30dp"
            app:cub_color="@color/colorwhite"
            app:cub_hover_color="@color/color_0288D1"
            app:cub_icon="@drawable/eat"
            app:cub_riple_effect="true" />


    </androidx.cardview.widget.CardView>

</LinearLayout>

Mahmoud Al-Haroon
  • 2,239
  • 7
  • 36
  • 72