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 6912013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:02:04+00:00 2026-05-27T09:02:04+00:00

I am trying to center the image that I am adding to my Alert

  • 0

I am trying to center the image that I am adding to my Alert Dialog in an Android app as follows:

    android.app.AlertDialog.Builder appInfoDialog = new AlertDialog.Builder(this);

    appInfoDialog.setIcon(R.drawable.image);
    appInfoDialog.setTitle(" ");
    appInfoDialog.setMessage("App Info...");

    appInfoDialog.setCancelable(true);

    AlertDialog dialog = appInfoDialog.create();
    dialog.show();  

But how can I center this image? Currently, it is left-aligned.

I cannot find a gravity or layout_align property for it!

  • 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-27T09:02:04+00:00Added an answer on May 27, 2026 at 9:02 am

    You can not do this, but You can create Your own Dialog like this:

    /values/themes.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <style name="Dialog" parent="android:style/Theme.Dialog">
            <item name="android:windowBackground">@null</item>
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowIsFloating">true</item>
        </style>
    
    </resources>
    

    /layout/custom_dialog.xml

    <?xml version="1.0" encoding="utf-8"?>
    

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dip"
            android:text="wpisz tekst by wyszukać piosenkę"
            android:textColor="#5E636D" />
    
        <EditText
            android:id="@+id/value_mini"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="40.0dip"
            android:background="@drawable/input_text"
            android:paddingLeft="10px" />
    
        <Button
            android:id="@+id/search_mini"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="80dip"
            android:text="szukaj" />
    </RelativeLayout>
    

    in method:

                Dialog dialog = new Dialog(Start.this, R.style.Dialog);
                dialog.setContentView(R.layout.custom_dialog);
                Button button = (Button) dialog.findViewById(R.id.search_mini);
                final EditText et = (EditText) dialog.findViewById(R.id.value_mini);
                button.setOnClickListener(new OnClickListener() {
                @Override
                    public void onClick(View v) {
                        //do something
                    }
                });
                dialog.show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to center align an image that is wrapped in a <span>
I'm trying to center a div that overlays the entire image. I have a
I gave up on trying to center an image vertically and horizontally. I seen
I'm trying to center a rotated image into a destination buffer using GDI+. The
I'm trying to black out the screen and center an image in the middle
I am trying to rotate image single round from it's center point but I
I'm trying to have an image that when clicked associates the selected guideline to
I'm trying to stretch a navigation arrow image while preserving the edges so that
I'm trying to center the names(#box2) and the topic(#box1) on top of an image.
I am using jQuery mobile and I am trying to center some image icons

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.