Dmitry
Dmitry

Reputation: 126

difficult design for buttons - Android Studio

How to do buttons with more difficult design?

I'm doing app for smart lamps and boards and I need to do device selection buttons like in template. How to do buttons with 1 ImageView and 2 TextView?

Template:

template

Upvotes: 0

Views: 59

Answers (2)

AgentP
AgentP

Reputation: 7220

Just for your reference one way to do this is like this...

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

<com.google.android.material.card.MaterialCardView
    android:layout_width="match_parent"
    android:layout_margin="16dp"
    android:padding="8dp"
    app:strokeColor="@color/black"
    app:strokeWidth="2dp"
    app:cardCornerRadius="8dp"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="8dp"
        android:weightSum="10">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="7"
            android:layout_gravity="center"
            android:orientation="vertical"
            android:layout_height="wrap_content">

            <TextView
                android:layout_width="match_parent"
                android:text="Big Title"
                android:textSize="25sp"
                android:paddingTop="8dp"
                android:paddingLeft="8dp"
                android:textStyle="bold"
                android:layout_height="wrap_content"/>


            <TextView
                android:layout_width="match_parent"
                android:text="small Title"
                android:textSize="16sp"
                android:paddingLeft="8dp"
                android:layout_height="wrap_content"/>

        </LinearLayout>

        <ImageView
            android:layout_width="0dp"
            android:layout_weight="3"
            android:src="@drawable/apple"
            android:layout_height="100dp"/>


    </LinearLayout>

</com.google.android.material.card.MaterialCardView>


</LinearLayout>

The output will be like this...

enter image description here

Upvotes: 3

KvaksMan play
KvaksMan play

Reputation: 230

Combine Views and do OnClickListener for this Views

Upvotes: 1

Related Questions