Home > Software design >  imagecircleview and textview side by side
imagecircleview and textview side by side

Time:11-25

I want to make imagecircleview and textview lie side by side in xml kotlin android. I have tried this but the textview lies above the imageview. The button is also above the image which I want at the bottom.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context=".FirstFragment">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

    <de.hdodenhof.circleimageview.CircleImageView
           android:id="@ id/imageview_profile"
           android:layout_width="120dp"
           android:layout_height="120dp"
           android:src="@drawable/kaleab_profile"
           android:layout_marginTop="60dp"/>
    <TextView
        android:id="@ id/textview_first"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="Kaleab Woldemariam"
        android:textColor="#000"
        android:textStyle="bold"
        android:layout_marginTop="5dp"/>
    </LinearLayout>
    <Button
        android:id="@ id/button_first"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/previous"
        android:layout_centerHorizontal="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/textview_first" />
</RelativeLayout>

CodePudding user response:

Try this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@ id/imageview_profile"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:src="@drawable/kaleab_profile" />

    <TextView
        android:id="@ id/textview_first"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_toEndOf="@ id/imageview_profile"
        android:text="Kaleab Woldemariam"
        android:textColor="#000"
        android:textStyle="bold" />

    <Button
        android:id="@ id/button_first"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Previous" />
</RelativeLayout>

CodePudding user response:

Try this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@ id/imageview_profile"
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:src="@drawable/profile_no_image" />

        <TextView
            android:id="@ id/textview_first"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginStart="20dp"
            android:layout_marginTop="5dp"
            android:layout_toEndOf="@ id/imageview_profile"
            android:gravity="center"
            android:text="Kaleab Woldemariam"
            android:textColor="#000"
            android:textStyle="bold" />
    </LinearLayout>

    <Button
        android:id="@ id/button_first"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:text="Previous" />
</RelativeLayout>
  • Related