How to remove the extra space from custom AlertDialogHow to control the width and height of the default Alert Dialog in Android?Removing an activity from the history stackHow to send an object from one Android Activity to another using Intents?How can I open a URL in Android's web browser from my application?How to change theme for AlertDialogHow to hide the title bar for an Activity in XML with existing custom themeHow to prevent a dialog from closing when a button is clickedHow to implement a custom AlertDialog ViewHow do I get extra data from intent on Android?How to add dividers and spaces between items in RecyclerView?Remove unnecessary space from AlertDialog
Why don't politicians push for fossil fuel reduction by pointing out their scarcity?
Can you be convicted for being a murderer twice?
How much code would a codegolf golf if a codegolf could golf code?
Is it appropriate for a prospective landlord to ask me for my credit report?
Thread-safe, Convenient and Performant Random Number Generator
Why does my house heat up, even when it's cool outside?
If all closed subsets of a set are compact, does it follow that this set is subset of a compact set?
Why is Boris Johnson visiting only Paris & Berlin if every member of the EU needs to agree on a withdrawal deal?
How to "know" if I have a passion?
Can I submit a paper under an alias so as to avoid trouble in my country?
How to organize ideas to start writing a novel?
Running script line by line automatically yet being asked before each line from second line onwards
What can I do to keep a threaded bolt from falling out of it’s slot
How to avoid using System.String with Rfc2898DeriveBytes in C#
Does Git delete empty folders?
Was this pillow joke on Friends intentional or a mistake?
Potential new partner angry about first collaboration - how to answer email to close up this encounter in a graceful manner
Is refusing to concede in the face of an unstoppable Nexus combo punishable?
Designing a prison for a telekinetic race
Can you feel passing through the sound barrier in an F-16?
Are required indicators necessary for radio buttons?
Can pay be witheld for hours cleaning up after closing time?
Can a group have a cyclical derived series?
What professions would a medieval village with a population of 100 need?
How to remove the extra space from custom AlertDialog
How to control the width and height of the default Alert Dialog in Android?Removing an activity from the history stackHow to send an object from one Android Activity to another using Intents?How can I open a URL in Android's web browser from my application?How to change theme for AlertDialogHow to hide the title bar for an Activity in XML with existing custom themeHow to prevent a dialog from closing when a button is clickedHow to implement a custom AlertDialog ViewHow do I get extra data from intent on Android?How to add dividers and spaces between items in RecyclerView?Remove unnecessary space from AlertDialog
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to make a custom AlertDialog. The issue is the extra space in the dialog (white rectangle at the pic). How to remove it?
here is my code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
in activity:
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final AlertDialog alertDialog = builder.create();
View view1 = LayoutInflater.from(context).inflate(R.layout.layout_for_long_like_button_option, null);
android android-alertdialog
add a comment |
I am trying to make a custom AlertDialog. The issue is the extra space in the dialog (white rectangle at the pic). How to remove it?
here is my code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
in activity:
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final AlertDialog alertDialog = builder.create();
View view1 = LayoutInflater.from(context).inflate(R.layout.layout_for_long_like_button_option, null);
android android-alertdialog
add a comment |
I am trying to make a custom AlertDialog. The issue is the extra space in the dialog (white rectangle at the pic). How to remove it?
here is my code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
in activity:
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final AlertDialog alertDialog = builder.create();
View view1 = LayoutInflater.from(context).inflate(R.layout.layout_for_long_like_button_option, null);
android android-alertdialog
I am trying to make a custom AlertDialog. The issue is the extra space in the dialog (white rectangle at the pic). How to remove it?
here is my code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
in activity:
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final AlertDialog alertDialog = builder.create();
View view1 = LayoutInflater.from(context).inflate(R.layout.layout_for_long_like_button_option, null);
android android-alertdialog
android android-alertdialog
edited Mar 27 at 15:43
Alexey
3,1491 gold badge20 silver badges27 bronze badges
3,1491 gold badge20 silver badges27 bronze badges
asked Mar 27 at 15:27
Imranrana07Imranrana07
619 bronze badges
619 bronze badges
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
As an option, if you would create custom dialog, you can do like this:
@Override
public void onStart()
super.onStart();
Dialog dialog = getDialog();
if (dialog != null)
int width = ViewGroup.LayoutParams.WRAP_CONTENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
dialog.getWindow().setLayout(width, height);
this is not working :(
– Imranrana07
Mar 27 at 15:54
then set background to transparent in theme to this dialog
– Jurij Pitulja
Mar 27 at 15:56
i did not use theme
– Imranrana07
Mar 27 at 15:58
add a comment |
Try this layout and customize. There is no need to nested linear layout. It causes performance problems.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:background="@color/colorPrimary"
android:padding="4dp">
<ImageButton
android:id="@+id/likeIconId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/wowButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/blehButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/dislikeButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
</LinearLayout>
And in activity or fragment you can call like this. There is no need to use alert dialog.
private fun showDialog(context: Context)
val dialog = Dialog(context)
dialog.setContentView(R.layout.layout_for_long_like_button_option)
dialog.show()
sorry, not working
– Imranrana07
Mar 27 at 16:04
Can you post your screen shot with this code? Because its working for me.
– toffor
Mar 27 at 16:05
okay wait please
– Imranrana07
Mar 27 at 16:08
ibb.co/wsYzJyJ
– Imranrana07
Mar 27 at 16:14
please check the pic
– Imranrana07
Mar 27 at 16:15
|
show 12 more comments
Just update the layout_width
of your parent LinearLayout
and the immediate child LinearLayout
to match_parent
instead of wrap_content
. See the update code below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
Update:
Try setting transparent background to your alert dialog after you called the alertDialog.show()
.
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
i want to remove the white space( there will just be icon like facebook like button popup), rather than extending the layout to the alertdialog size.
– Imranrana07
Mar 27 at 15:46
@Imranrana07 got your point, I have updated my answer above, try it please
– sourav.bh
Mar 27 at 16:26
its just making background transparent. i am trying to make like facebook like button. if you can please help me
– Imranrana07
Mar 27 at 16:33
but your question was about removing that extra white background, please be specific about what you want and that's the only way we can help you
– sourav.bh
Mar 27 at 16:36
sorry, its a simple mistake, but i told you i want like facebook like button which popup just above the button.
– Imranrana07
Mar 27 at 16:53
|
show 3 more comments
thank you guys for your kind cooperation. i have solved my problem by myself. i just added a layout to the position i want and solved all. thank you again
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%2f55380901%2fhow-to-remove-the-extra-space-from-custom-alertdialog%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
As an option, if you would create custom dialog, you can do like this:
@Override
public void onStart()
super.onStart();
Dialog dialog = getDialog();
if (dialog != null)
int width = ViewGroup.LayoutParams.WRAP_CONTENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
dialog.getWindow().setLayout(width, height);
this is not working :(
– Imranrana07
Mar 27 at 15:54
then set background to transparent in theme to this dialog
– Jurij Pitulja
Mar 27 at 15:56
i did not use theme
– Imranrana07
Mar 27 at 15:58
add a comment |
As an option, if you would create custom dialog, you can do like this:
@Override
public void onStart()
super.onStart();
Dialog dialog = getDialog();
if (dialog != null)
int width = ViewGroup.LayoutParams.WRAP_CONTENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
dialog.getWindow().setLayout(width, height);
this is not working :(
– Imranrana07
Mar 27 at 15:54
then set background to transparent in theme to this dialog
– Jurij Pitulja
Mar 27 at 15:56
i did not use theme
– Imranrana07
Mar 27 at 15:58
add a comment |
As an option, if you would create custom dialog, you can do like this:
@Override
public void onStart()
super.onStart();
Dialog dialog = getDialog();
if (dialog != null)
int width = ViewGroup.LayoutParams.WRAP_CONTENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
dialog.getWindow().setLayout(width, height);
As an option, if you would create custom dialog, you can do like this:
@Override
public void onStart()
super.onStart();
Dialog dialog = getDialog();
if (dialog != null)
int width = ViewGroup.LayoutParams.WRAP_CONTENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
dialog.getWindow().setLayout(width, height);
answered Mar 27 at 15:50
Jurij PituljaJurij Pitulja
1,0021 gold badge7 silver badges14 bronze badges
1,0021 gold badge7 silver badges14 bronze badges
this is not working :(
– Imranrana07
Mar 27 at 15:54
then set background to transparent in theme to this dialog
– Jurij Pitulja
Mar 27 at 15:56
i did not use theme
– Imranrana07
Mar 27 at 15:58
add a comment |
this is not working :(
– Imranrana07
Mar 27 at 15:54
then set background to transparent in theme to this dialog
– Jurij Pitulja
Mar 27 at 15:56
i did not use theme
– Imranrana07
Mar 27 at 15:58
this is not working :(
– Imranrana07
Mar 27 at 15:54
this is not working :(
– Imranrana07
Mar 27 at 15:54
then set background to transparent in theme to this dialog
– Jurij Pitulja
Mar 27 at 15:56
then set background to transparent in theme to this dialog
– Jurij Pitulja
Mar 27 at 15:56
i did not use theme
– Imranrana07
Mar 27 at 15:58
i did not use theme
– Imranrana07
Mar 27 at 15:58
add a comment |
Try this layout and customize. There is no need to nested linear layout. It causes performance problems.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:background="@color/colorPrimary"
android:padding="4dp">
<ImageButton
android:id="@+id/likeIconId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/wowButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/blehButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/dislikeButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
</LinearLayout>
And in activity or fragment you can call like this. There is no need to use alert dialog.
private fun showDialog(context: Context)
val dialog = Dialog(context)
dialog.setContentView(R.layout.layout_for_long_like_button_option)
dialog.show()
sorry, not working
– Imranrana07
Mar 27 at 16:04
Can you post your screen shot with this code? Because its working for me.
– toffor
Mar 27 at 16:05
okay wait please
– Imranrana07
Mar 27 at 16:08
ibb.co/wsYzJyJ
– Imranrana07
Mar 27 at 16:14
please check the pic
– Imranrana07
Mar 27 at 16:15
|
show 12 more comments
Try this layout and customize. There is no need to nested linear layout. It causes performance problems.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:background="@color/colorPrimary"
android:padding="4dp">
<ImageButton
android:id="@+id/likeIconId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/wowButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/blehButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/dislikeButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
</LinearLayout>
And in activity or fragment you can call like this. There is no need to use alert dialog.
private fun showDialog(context: Context)
val dialog = Dialog(context)
dialog.setContentView(R.layout.layout_for_long_like_button_option)
dialog.show()
sorry, not working
– Imranrana07
Mar 27 at 16:04
Can you post your screen shot with this code? Because its working for me.
– toffor
Mar 27 at 16:05
okay wait please
– Imranrana07
Mar 27 at 16:08
ibb.co/wsYzJyJ
– Imranrana07
Mar 27 at 16:14
please check the pic
– Imranrana07
Mar 27 at 16:15
|
show 12 more comments
Try this layout and customize. There is no need to nested linear layout. It causes performance problems.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:background="@color/colorPrimary"
android:padding="4dp">
<ImageButton
android:id="@+id/likeIconId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/wowButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/blehButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/dislikeButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
</LinearLayout>
And in activity or fragment you can call like this. There is no need to use alert dialog.
private fun showDialog(context: Context)
val dialog = Dialog(context)
dialog.setContentView(R.layout.layout_for_long_like_button_option)
dialog.show()
Try this layout and customize. There is no need to nested linear layout. It causes performance problems.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:background="@color/colorPrimary"
android:padding="4dp">
<ImageButton
android:id="@+id/likeIconId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/wowButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/blehButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<ImageButton
android:id="@+id/dislikeButtonId"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:adjustViewBounds="true"
android:src="@android:drawable/ic_delete"/>
</LinearLayout>
And in activity or fragment you can call like this. There is no need to use alert dialog.
private fun showDialog(context: Context)
val dialog = Dialog(context)
dialog.setContentView(R.layout.layout_for_long_like_button_option)
dialog.show()
answered Mar 27 at 15:59
toffortoffor
1801 silver badge10 bronze badges
1801 silver badge10 bronze badges
sorry, not working
– Imranrana07
Mar 27 at 16:04
Can you post your screen shot with this code? Because its working for me.
– toffor
Mar 27 at 16:05
okay wait please
– Imranrana07
Mar 27 at 16:08
ibb.co/wsYzJyJ
– Imranrana07
Mar 27 at 16:14
please check the pic
– Imranrana07
Mar 27 at 16:15
|
show 12 more comments
sorry, not working
– Imranrana07
Mar 27 at 16:04
Can you post your screen shot with this code? Because its working for me.
– toffor
Mar 27 at 16:05
okay wait please
– Imranrana07
Mar 27 at 16:08
ibb.co/wsYzJyJ
– Imranrana07
Mar 27 at 16:14
please check the pic
– Imranrana07
Mar 27 at 16:15
sorry, not working
– Imranrana07
Mar 27 at 16:04
sorry, not working
– Imranrana07
Mar 27 at 16:04
Can you post your screen shot with this code? Because its working for me.
– toffor
Mar 27 at 16:05
Can you post your screen shot with this code? Because its working for me.
– toffor
Mar 27 at 16:05
okay wait please
– Imranrana07
Mar 27 at 16:08
okay wait please
– Imranrana07
Mar 27 at 16:08
ibb.co/wsYzJyJ
– Imranrana07
Mar 27 at 16:14
ibb.co/wsYzJyJ
– Imranrana07
Mar 27 at 16:14
please check the pic
– Imranrana07
Mar 27 at 16:15
please check the pic
– Imranrana07
Mar 27 at 16:15
|
show 12 more comments
Just update the layout_width
of your parent LinearLayout
and the immediate child LinearLayout
to match_parent
instead of wrap_content
. See the update code below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
Update:
Try setting transparent background to your alert dialog after you called the alertDialog.show()
.
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
i want to remove the white space( there will just be icon like facebook like button popup), rather than extending the layout to the alertdialog size.
– Imranrana07
Mar 27 at 15:46
@Imranrana07 got your point, I have updated my answer above, try it please
– sourav.bh
Mar 27 at 16:26
its just making background transparent. i am trying to make like facebook like button. if you can please help me
– Imranrana07
Mar 27 at 16:33
but your question was about removing that extra white background, please be specific about what you want and that's the only way we can help you
– sourav.bh
Mar 27 at 16:36
sorry, its a simple mistake, but i told you i want like facebook like button which popup just above the button.
– Imranrana07
Mar 27 at 16:53
|
show 3 more comments
Just update the layout_width
of your parent LinearLayout
and the immediate child LinearLayout
to match_parent
instead of wrap_content
. See the update code below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
Update:
Try setting transparent background to your alert dialog after you called the alertDialog.show()
.
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
i want to remove the white space( there will just be icon like facebook like button popup), rather than extending the layout to the alertdialog size.
– Imranrana07
Mar 27 at 15:46
@Imranrana07 got your point, I have updated my answer above, try it please
– sourav.bh
Mar 27 at 16:26
its just making background transparent. i am trying to make like facebook like button. if you can please help me
– Imranrana07
Mar 27 at 16:33
but your question was about removing that extra white background, please be specific about what you want and that's the only way we can help you
– sourav.bh
Mar 27 at 16:36
sorry, its a simple mistake, but i told you i want like facebook like button which popup just above the button.
– Imranrana07
Mar 27 at 16:53
|
show 3 more comments
Just update the layout_width
of your parent LinearLayout
and the immediate child LinearLayout
to match_parent
instead of wrap_content
. See the update code below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
Update:
Try setting transparent background to your alert dialog after you called the alertDialog.show()
.
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Just update the layout_width
of your parent LinearLayout
and the immediate child LinearLayout
to match_parent
instead of wrap_content
. See the update code below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="@drawable/round_alert_like_ui">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/like_icon"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:id="@+id/likeIconId"
android:fitsSystemWindows="true"
android:padding="5dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wowButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/love_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="40dp"
android:layout_height="35dp"
android:id="@+id/blehButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/bleh"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dislikeButtonId"
android:layout_marginStart="5dp"
android:src="@drawable/dislike_icon"
android:background="@drawable/round_button_for_round_menu_like_button"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
Update:
Try setting transparent background to your alert dialog after you called the alertDialog.show()
.
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
edited Mar 27 at 16:25
answered Mar 27 at 15:40
sourav.bhsourav.bh
4441 gold badge5 silver badges19 bronze badges
4441 gold badge5 silver badges19 bronze badges
i want to remove the white space( there will just be icon like facebook like button popup), rather than extending the layout to the alertdialog size.
– Imranrana07
Mar 27 at 15:46
@Imranrana07 got your point, I have updated my answer above, try it please
– sourav.bh
Mar 27 at 16:26
its just making background transparent. i am trying to make like facebook like button. if you can please help me
– Imranrana07
Mar 27 at 16:33
but your question was about removing that extra white background, please be specific about what you want and that's the only way we can help you
– sourav.bh
Mar 27 at 16:36
sorry, its a simple mistake, but i told you i want like facebook like button which popup just above the button.
– Imranrana07
Mar 27 at 16:53
|
show 3 more comments
i want to remove the white space( there will just be icon like facebook like button popup), rather than extending the layout to the alertdialog size.
– Imranrana07
Mar 27 at 15:46
@Imranrana07 got your point, I have updated my answer above, try it please
– sourav.bh
Mar 27 at 16:26
its just making background transparent. i am trying to make like facebook like button. if you can please help me
– Imranrana07
Mar 27 at 16:33
but your question was about removing that extra white background, please be specific about what you want and that's the only way we can help you
– sourav.bh
Mar 27 at 16:36
sorry, its a simple mistake, but i told you i want like facebook like button which popup just above the button.
– Imranrana07
Mar 27 at 16:53
i want to remove the white space( there will just be icon like facebook like button popup), rather than extending the layout to the alertdialog size.
– Imranrana07
Mar 27 at 15:46
i want to remove the white space( there will just be icon like facebook like button popup), rather than extending the layout to the alertdialog size.
– Imranrana07
Mar 27 at 15:46
@Imranrana07 got your point, I have updated my answer above, try it please
– sourav.bh
Mar 27 at 16:26
@Imranrana07 got your point, I have updated my answer above, try it please
– sourav.bh
Mar 27 at 16:26
its just making background transparent. i am trying to make like facebook like button. if you can please help me
– Imranrana07
Mar 27 at 16:33
its just making background transparent. i am trying to make like facebook like button. if you can please help me
– Imranrana07
Mar 27 at 16:33
but your question was about removing that extra white background, please be specific about what you want and that's the only way we can help you
– sourav.bh
Mar 27 at 16:36
but your question was about removing that extra white background, please be specific about what you want and that's the only way we can help you
– sourav.bh
Mar 27 at 16:36
sorry, its a simple mistake, but i told you i want like facebook like button which popup just above the button.
– Imranrana07
Mar 27 at 16:53
sorry, its a simple mistake, but i told you i want like facebook like button which popup just above the button.
– Imranrana07
Mar 27 at 16:53
|
show 3 more comments
thank you guys for your kind cooperation. i have solved my problem by myself. i just added a layout to the position i want and solved all. thank you again
add a comment |
thank you guys for your kind cooperation. i have solved my problem by myself. i just added a layout to the position i want and solved all. thank you again
add a comment |
thank you guys for your kind cooperation. i have solved my problem by myself. i just added a layout to the position i want and solved all. thank you again
thank you guys for your kind cooperation. i have solved my problem by myself. i just added a layout to the position i want and solved all. thank you again
answered Mar 28 at 6:09
Imranrana07Imranrana07
619 bronze badges
619 bronze badges
add a comment |
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%2f55380901%2fhow-to-remove-the-extra-space-from-custom-alertdialog%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