How to implement a overlapping TextView in a ImageView, which combinely works as a Button?
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?

|
show 3 more comments
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?

What have you tried for it?
– Rumit Patel
Jan 1 at 6:39
Possible duplicate of Android: combining text & image on a Button or ImageButton
– tomerpacific
Jan 1 at 6:42
1
You can use FrameLayout to put a View over Another Here
– Mohamad Armoon
Jan 1 at 6:43
@RumitPatel I've tried using FrameLayout
– Harish V
Jan 1 at 6:44
1
Use RelativeLayout, FrameLayout or ConstrainLayout
– Piyush
Jan 1 at 6:44
|
show 3 more comments
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?

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?

edited Jan 1 at 16:06
sourav.bh
365216
365216
asked Jan 1 at 6:37
Harish VHarish V
37
37
What have you tried for it?
– Rumit Patel
Jan 1 at 6:39
Possible duplicate of Android: combining text & image on a Button or ImageButton
– tomerpacific
Jan 1 at 6:42
1
You can use FrameLayout to put a View over Another Here
– Mohamad Armoon
Jan 1 at 6:43
@RumitPatel I've tried using FrameLayout
– Harish V
Jan 1 at 6:44
1
Use RelativeLayout, FrameLayout or ConstrainLayout
– Piyush
Jan 1 at 6:44
|
show 3 more comments
What have you tried for it?
– Rumit Patel
Jan 1 at 6:39
Possible duplicate of Android: combining text & image on a Button or ImageButton
– tomerpacific
Jan 1 at 6:42
1
You can use FrameLayout to put a View over Another Here
– Mohamad Armoon
Jan 1 at 6:43
@RumitPatel I've tried using FrameLayout
– Harish V
Jan 1 at 6:44
1
Use RelativeLayout, FrameLayout or ConstrainLayout
– Piyush
Jan 1 at 6:44
What have you tried for it?
– Rumit Patel
Jan 1 at 6:39
What have you tried for it?
– Rumit Patel
Jan 1 at 6:39
Possible duplicate of Android: combining text & image on a Button or ImageButton
– tomerpacific
Jan 1 at 6:42
Possible duplicate of Android: combining text & image on a Button or ImageButton
– tomerpacific
Jan 1 at 6:42
1
1
You can use FrameLayout to put a View over Another Here
– Mohamad Armoon
Jan 1 at 6:43
You can use FrameLayout to put a View over Another Here
– Mohamad Armoon
Jan 1 at 6:43
@RumitPatel I've tried using FrameLayout
– Harish V
Jan 1 at 6:44
@RumitPatel I've tried using FrameLayout
– Harish V
Jan 1 at 6:44
1
1
Use RelativeLayout, FrameLayout or ConstrainLayout
– Piyush
Jan 1 at 6:44
Use RelativeLayout, FrameLayout or ConstrainLayout
– Piyush
Jan 1 at 6:44
|
show 3 more comments
1 Answer
1
active
oldest
votes
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>
But I need it in a GridLayout and it should be a button!
– Harish V
Jan 1 at 6:57
Check my edited answer. You can customize it according to your requirements @HarishV
– Mittal Varsani
Jan 1 at 7:22
Thank you for this!
– Harish V
Jan 1 at 16:04
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993502%2fhow-to-implement-a-overlapping-textview-in-a-imageview-which-combinely-works-as%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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>
But I need it in a GridLayout and it should be a button!
– Harish V
Jan 1 at 6:57
Check my edited answer. You can customize it according to your requirements @HarishV
– Mittal Varsani
Jan 1 at 7:22
Thank you for this!
– Harish V
Jan 1 at 16:04
add a comment |
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>
But I need it in a GridLayout and it should be a button!
– Harish V
Jan 1 at 6:57
Check my edited answer. You can customize it according to your requirements @HarishV
– Mittal Varsani
Jan 1 at 7:22
Thank you for this!
– Harish V
Jan 1 at 16:04
add a comment |
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>
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>
edited Jan 1 at 7:18
answered Jan 1 at 6:45
Mittal VarsaniMittal Varsani
318311
318311
But I need it in a GridLayout and it should be a button!
– Harish V
Jan 1 at 6:57
Check my edited answer. You can customize it according to your requirements @HarishV
– Mittal Varsani
Jan 1 at 7:22
Thank you for this!
– Harish V
Jan 1 at 16:04
add a comment |
But I need it in a GridLayout and it should be a button!
– Harish V
Jan 1 at 6:57
Check my edited answer. You can customize it according to your requirements @HarishV
– Mittal Varsani
Jan 1 at 7:22
Thank you for this!
– Harish V
Jan 1 at 16:04
But I need it in a GridLayout and it should be a button!
– Harish V
Jan 1 at 6:57
But I need it in a GridLayout and it should be a button!
– Harish V
Jan 1 at 6:57
Check my edited answer. You can customize it according to your requirements @HarishV
– Mittal Varsani
Jan 1 at 7:22
Check my edited answer. You can customize it according to your requirements @HarishV
– Mittal Varsani
Jan 1 at 7:22
Thank you for this!
– Harish V
Jan 1 at 16:04
Thank you for this!
– Harish V
Jan 1 at 16:04
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993502%2fhow-to-implement-a-overlapping-textview-in-a-imageview-which-combinely-works-as%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What have you tried for it?
– Rumit Patel
Jan 1 at 6:39
Possible duplicate of Android: combining text & image on a Button or ImageButton
– tomerpacific
Jan 1 at 6:42
1
You can use FrameLayout to put a View over Another Here
– Mohamad Armoon
Jan 1 at 6:43
@RumitPatel I've tried using FrameLayout
– Harish V
Jan 1 at 6:44
1
Use RelativeLayout, FrameLayout or ConstrainLayout
– Piyush
Jan 1 at 6:44