Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:22:35+00:00 2026-05-25T12:22:35+00:00

I am creating a custom dialog as: Dialog myDialog = new Dialog(context, R.style.Theme_Levels); myDialog.setContentView(R.layout.levelselector);

  • 0

I am creating a custom dialog as:

    Dialog myDialog = new Dialog(context, R.style.Theme_Levels);
    myDialog.setContentView(R.layout.levelselector);
    myDialog.show();

Style used:

<style name="Theme.Levels" parent="@android:style/Theme.Dialog">
   <item name="android:windowFrame">@null</item>
   <item name="android:windowIsFloating">true</item>
   <item name="android:windowBackground">@drawable/dlgbg</item>
   <item name="android:windowContentOverlay">@null</item>
   <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
   <item name="android:windowNoTitle">true</item>
   <item name="android:backgroundDimEnabled">false</item>
</style>

Layout xml file:

<LinearLayout android:id="@+id/LevelSelector" 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_height="fill_parent" 
  android:layout_width="fill_parent" 
  android:layout_gravity="bottom|center_horizontal"
  android:paddingBottom="50dip"
  >     

    <Button android:text="Easy" 
        android:id="@+id/btn_Easy" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
    />
</LinearLayout>

I want the button to appear at bottom center of the dialog (50dip padding from bottom) but it appears at top left of the Dialog.

Thats because LinearLayout does not know the width/height of the dialog, which is the size of the background image I have used in style xml file.

Question: How do I know the width height of the dialog so that LinearLayout is of the same size as the Dialog size?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:22:36+00:00Added an answer on May 25, 2026 at 12:22 pm

    Ok, I have found a way, not a clean way but works.

    You need to add background in style.xml file

       <item name="android:windowBackground">@drawable/levelselectbg</item> 
    

    AND also in you linearlayout:

    android:background="@drawable/levelselectbg"
    

    The first background is required to keep the dialog borderless (which I have specified in my style.xml in my question) and the linearlayout background is required to give size to the layout, now it knows its dimensions and places the button at bottom center with padding.

    Hope this helps someone, if a better solution is available please share.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show custom dialog like iphone hud progress Bar Style.but,i am no
I'm creating a custom Holo theme in which I want to customize Dialog look
I am new to magento and i am Creating Custom module for File upload
After creating a custom Dialog using a ListView and my own implementation of ListAdapter
I want to add a custom Dialog, but I have problems creating a xml
i'm currently creating a custom dialog (alertdialog is not flexible enough for my needs).
I'm working on creating a custom dialog to get input from the user. I've
I am creating a custom wxPython dialog by subclassing wx.Dialog . When I press
I'm creating a custom dialog with a background image which has rounded corners. I
I have a problem creating a custom dialog. But I don't find the failure.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.