I am new to Android development and I need to know if I can overlap an imageView and a TextView together into a button. It should be similar to the image that I've shared and I need to frame it in a GridLayout with 2 columns. If I use FrameLayout for each imageView and textView it becomes little complex, is there any alternative method?
Asked
Active
Viewed 181 times
0
-
What have you tried for it? – Rumit Patel Jan 01 '19 at 06:39
-
Possible duplicate of [Android: combining text & image on a Button or ImageButton](https://stackoverflow.com/questions/1532876/android-combining-text-image-on-a-button-or-imagebutton) – tomerpacific Jan 01 '19 at 06:42
-
1You can use FrameLayout to put a View over Another [Here](https://stackoverflow.com/questions/25679369/what-does-framelayout-do) – M.Armoun Jan 01 '19 at 06:43
-
@RumitPatel I've tried using FrameLayout – Harish V Jan 01 '19 at 06:44
-
1Use _RelativeLayout_, _FrameLayout_ or _ConstrainLayout_ – Piyush Jan 01 '19 at 06:44
-
@Piyush Will try. Thanks! – Harish V Jan 01 '19 at 06:55
-
You can do it with Relativelayout – Maitri Jan 01 '19 at 09:12
-
@Maitri Yeah! Tried it.. – Harish V Jan 01 '19 at 16:05
1 Answers
0
Try this and run...if any error occurs please tell me I will help
<?xml version="1.0" encoding="utf-8"?>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/img_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/your_image"
android:scaleType="centerCrop"
android:textColor="@color/colorBlack"
android:text="Title"
android:textSize="25sp"/>
</GridLayout>

Mittal Varsani
- 5,601
- 2
- 15
- 27
-
-
Check my edited answer. You can customize it according to your requirements @HarishV – Mittal Varsani Jan 01 '19 at 07:22
-