Skip to content Skip to sidebar Skip to footer

Possible To Make A Beehive Xml Layout In Android?

A beehive layout should look like this The colored hives are just so you understand how I have to lay down elements. Which Layout widget do you suggest of using? I tried with Gri

Solution 1:

This answer is too late, but someone may find the solution from this, so I am answering this question

I made a simple honeycomb view using ConstraintLayout.

here is the code, You can replace ImageView with any other view

<?xml version="1.0" encoding="utf-8"?>
<layout 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">

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".fragment.MyFragment">

    <com.myapp.widget.CustomTextView
        android:id="@+id/iv_1"
        style="@style/tv_style"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/honey_comb_center"
        android:gravity="center"
        android:text="Total\nInvestment"
        app:fontName="@string/font_bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/iv_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/_5sdp"
        android:src="@drawable/honey_comb"
        app:layout_constraintBottom_toBottomOf="@id/iv_1"
        app:layout_constraintRight_toLeftOf="@id/iv_1"
        app:layout_constraintTop_toTopOf="@id/iv_1" />

    <ImageView
        android:id="@+id/iv_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/_5sdp"
        android:src="@drawable/honey_comb"
        app:layout_constraintBottom_toBottomOf="@id/iv_1"
        app:layout_constraintLeft_toRightOf="@id/iv_1"
        app:layout_constraintTop_toTopOf="@id/iv_1" />

    <ImageView
        android:id="@+id/iv_4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/honey_comb"
        android:translationY="@dimen/_20sdp"
        app:layout_constraintBottom_toTopOf="@id/iv_1"
        app:layout_constraintLeft_toLeftOf="@id/iv_2"
        app:layout_constraintRight_toRightOf="@id/iv_1" />

    <ImageView
        android:id="@+id/iv_5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/honey_comb"
        android:translationY="@dimen/_20sdp"
        app:layout_constraintBottom_toTopOf="@id/iv_1"
        app:layout_constraintLeft_toLeftOf="@id/iv_1"
        app:layout_constraintRight_toRightOf="@id/iv_3" />

    <ImageView
        android:id="@+id/iv_6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/honey_comb"
        android:translationY="@dimen/_minus20sdp"
        app:layout_constraintLeft_toLeftOf="@id/iv_2"
        app:layout_constraintRight_toRightOf="@id/iv_1"
        app:layout_constraintTop_toBottomOf="@id/iv_1" />

    <ImageView
        android:id="@+id/iv_7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/honey_comb"
        android:translationY="@dimen/_minus20sdp"
        app:layout_constraintLeft_toLeftOf="@id/iv_1"
        app:layout_constraintRight_toRightOf="@id/iv_3"
        app:layout_constraintTop_toBottomOf="@id/iv_1" />

</androidx.constraintlayout.widget.ConstraintLayout>

here is the screenshot enter image description here

Post a Comment for "Possible To Make A Beehive Xml Layout In Android?"