Matt
Matt

Reputation: 3912

Add multiple Strings and ImageViews to one View

What I want to do is have something like the picture below.

enter image description here

The whole rounded corner rectangle needs to be clickable. Then Record: ### and ### need to be some sort of TextView or String. The green check mark needs to be an ImageView.

I am having trouble even knowing where to start with this. I know there is a way to achieve this because the app Unblock Me has something sort of like how I want it. Below is a screenshot of their app.

enter image description here

Any help on ideas of how to achieve this?

Upvotes: 0

Views: 54

Answers (1)

Rahul Gupta
Rahul Gupta

Reputation: 5295

It is kind of easy.

First that rounded rectangle can be a linear layout ok. In its background attribute you pass a layer list which will contain two items having colors black and white with radius of lets say 5dp

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <!-- "background shadow" -->
    <item>
        <shape android:shape="rectangle" >
            <solid android:color="#DDDDDD" />

            <corners android:radius="15dp" />
        </shape>
    </item>
    <!-- background color -->
    <item
        android:bottom="5px"
        android:left="5px"
        android:right="5px"
        android:top="5px">
        <shape android:shape="rectangle" >
            <solid android:color="#FFFFFF" />


            <corners android:radius="8dp" />
        </shape>
    </item>
</layer-list>

put this in a xml file and save it in a drawable folder and put it in the background attribute of your linear layout.

Now in your layout, with orientation horizontal, put three child elements

two textviews and one imageview with weights 35, 35, 30 and set image to the imageview that green tick mark sign. Voila!

Upvotes: 1

Related Questions