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

  • Home
  • SEARCH
  • 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 8578057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:18:02+00:00 2026-06-11T20:18:02+00:00

I have a custom dialog for my android application.it shows an image and text

  • 0

I have a custom dialog for my android application.it shows an image and text with two buttons at left and right.Here is my dialog

public class GalleryPopUp extends Dialog {

    private Context context;
    private ArrayList<Bitmap> bitmapList = null;
    private List<News> homeNewsList = null;
    private Button btnArrowLeft;
    private Button btnArrowRight;
    private ImageView imageView;
    private int selectedIndex = 0;
    private TextView textView;
    static final RelativeLayout.LayoutParams FILL = new RelativeLayout.LayoutParams(
            LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);

    public GalleryPopUp(Context context, ArrayList<Bitmap> bitmapList,
            List<News> homeNewsList, int selectedIndex) {
        super(context, android.R.style.Theme_Translucent_NoTitleBar);
        this.context = context;
        this.bitmapList = bitmapList;
        this.homeNewsList = homeNewsList;
        this.selectedIndex = selectedIndex;

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.gallery_popup, null);
        btnArrowLeft = (Button)view.findViewById(R.id.btnArrowLeft);
        btnArrowRight = (Button)view. findViewById(R.id.btnArrowRight);
        imageView = (ImageView) view.findViewById(R.id.imageView);
        textView = (TextView)view. findViewById(R.id.textView);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setImageBitmap(bitmapList.get(selectedIndex));
        News news = homeNewsList.get(selectedIndex);
        textView.setTextSize(15);
        textView.setTypeface(TypeFaceUtils.TYPEFACE_THOOLIKA);
        textView.setText(news.getNewsTitle());
        btnArrowLeft.setOnClickListener(listenerbtnArrowLeft);
        btnArrowRight.setOnClickListener(listenerbtnArrowRight);
        setContentView(view);
    }

    private android.view.View.OnClickListener listenerbtnArrowLeft = new android.view.View.OnClickListener() {

        @Override
        public void onClick(View v) {
            selectedIndex = selectedIndex - 1;
            if (selectedIndex < homeNewsList.size() && selectedIndex >= 0) {
                imageView.setImageBitmap(bitmapList.get(selectedIndex));
                News news = homeNewsList.get(selectedIndex);
                textView.setTypeface(TypeFaceUtils.TYPEFACE_THOOLIKA);
                textView.setText(news.getNewsTitle());
            }
            else
            {
                GalleryPopUp.this.dismiss();
            }
        }
    };

    private android.view.View.OnClickListener listenerbtnArrowRight = new android.view.View.OnClickListener() {

        @Override
        public void onClick(View v) {
            selectedIndex = selectedIndex + 1;
            if (selectedIndex < homeNewsList.size()) {
                imageView.setImageBitmap(bitmapList.get(selectedIndex));
                News news = homeNewsList.get(selectedIndex);
                textView.setTypeface(TypeFaceUtils.TYPEFACE_THOOLIKA);
                textView.setText(news.getNewsTitle());
            }
            else
            {
                GalleryPopUp.this.dismiss();
            }
        }
    };
}

gallery_popup.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView"
        android:layout_gravity="center_horizontal|bottom"
        android:gravity="center_horizontal"
        android:text=""
        android:textColor="#000000" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/imageView"
        android:gravity="center" >

        <Button
            android:id="@+id/btnArrowRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/btn_arrow_right" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView"
        android:layout_alignParentLeft="true"
        android:layout_alignTop="@+id/imageView"
        android:gravity="center" >

        <Button
            android:id="@+id/btnArrowLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:background="@drawable/btn_arrow_left" />
    </LinearLayout>

</RelativeLayout>

How can i show this dialog exactly at center of parent.?

  • 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-06-11T20:18:03+00:00Added an answer on June 11, 2026 at 8:18 pm

    The best way is to change your layout like this:

        <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        <RelativeLayout 
            android:id="@+id/relativeLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
    
        android:layout_centerInParent="true"
     >
    

    try it and let me know if it works.

            <TextView
                android:id="@+id/textView"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/imageView"
                android:layout_gravity="center_horizontal|bottom"
                android:gravity="center_horizontal"
                android:text=""
                android:textColor="#000000" />
    
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/imageView"
                android:layout_alignParentRight="true"
                android:layout_alignTop="@+id/imageView"
                android:gravity="center" >
    
                <Button
                    android:id="@+id/btnArrowRight"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/btn_arrow_right" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/imageView"
                android:layout_alignParentLeft="true"
                android:layout_alignTop="@+id/imageView"
                android:gravity="center" >
    
                <Button
                    android:id="@+id/btnArrowLeft"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@drawable/btn_arrow_left" />
            </LinearLayout>
    
        </RelativeLayout>
       </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom dialog with one editText view and two buttons ok and
I have a custom dialog in my android application. I want to have in
I have a custom Dialog that shows a few buttons. The idea is to
I have a custom dialog box displaying some text and a image underneath. The
I have a custom Dialog that contains only a TextView to display some text
In my android app i show a custom dialog. In this dialog i have
I have created a custom dialog box extending the DialogFragment class. As stated in
In my application I have a custom dialog which display some unwanted margin at
I have to implement a custom dialog in my application, But my codes seems
i have a small problem with writing my application.. I have custom dialog what

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.