Last Updated
Viewed 11 Times
     

I use AlertDialogs a lot in my project on multiple Activities.

On one om my activities the AlertDialog changed color on the buttons (making them ugly and unreadable).

I use the same theme all throughout my app.

AlertDialog alertDialog = new AlertDialog.Builder(CreateReservationActivity.this)
        .setMessage(alertMessage)
        .setTitle(alertTitle)
        .setNeutralButton("Ok", null) // ignore button click
        .setCancelable(true)
        .create();
alertDialog.show();

How it looks in one of the acitivities

enter image description here

How it looks in every other activity.

enter image description here

Comment if you need more information. I'm not sure what information is helpful and not.

Similar Question 1 : Change button color in AlertDialog

How can I change the color of the button(s) in an AlertDialog in Android?

Similar Question 2 : Button in an AlertDialog

How would I set up the onClickListener for a button inside an alertDialog? Do I just use the onClick of the whole activity or do I make a new one inside the alertDialog builder?

EDIT: Sorry I didn't make it clear first time but this isn't for the positive/negative buttons. This is for a button within a custom xml.

Thanks in advance

I am writing a simple tic tac toe application that has 3 by 3 array of buttons, when someone wins it changes colors, however when colors change it becomes of bigger size and you cannot see individual buttons? so my question is how do i make them change color but stay the same size? picture is instead of thousand words attached. the below code is non contiguous, first i initialize button to default, then when we have a winner color of winning buttons will change and then on game reset I return buttons to the default state; please tell me how to make button color red without it going out of button boundaries or if there is a better way to implement the entire thing.

button00.setBackgroundResource(android.R.drawable.btn_default);
button00.setBackgroundColor(Color.RED);
button00.setBackgroundResource(android.R.drawable.btn_default);

Layout XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

     <Button
        android:id="@+id/Button01"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/Button00"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_alignBaseline="@+id/Button01"
        android:layout_alignBottom="@+id/Button01"
        android:layout_toRightOf="@+id/Button01"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/Button02"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_alignBaseline="@+id/Button00"
        android:layout_alignBottom="@+id/Button00"
        android:layout_toRightOf="@+id/Button00"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/Button10"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_below="@+id/Button00"
        android:layout_toLeftOf="@+id/Button00"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/Button11"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_alignBaseline="@+id/Button10"
        android:layout_alignBottom="@+id/Button10"
        android:layout_toLeftOf="@+id/Button02"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/Button12"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_alignBaseline="@+id/Button11"
        android:layout_alignBottom="@+id/Button11"
        android:layout_alignLeft="@+id/Button02"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/Button20"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_alignLeft="@+id/Button10"
        android:layout_below="@+id/Button10"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/Button21"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_alignBaseline="@+id/Button20"
        android:layout_alignBottom="@+id/Button20"
        android:layout_toLeftOf="@+id/Button12"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/Button22"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_alignBaseline="@+id/Button21"
        android:layout_alignBottom="@+id/Button21"
        android:layout_alignLeft="@+id/Button12"
        android:text="@string/hello_world" />

         <TextView
            android:id="@+id/testButton"
            android:layout_width="260dp"
            android:layout_height="50dp"
            android:layout_alignLeft="@+id/Button20"
            android:layout_below="@+id/Button20"
            android:text="@string/hello_world" />
     <!-- 
        <Button
            android:id="@+id/resetButton"
            android:layout_width="260dp"
            android:layout_height="90dp"
            android:layout_alignLeft="@+id/testButton"
            android:layout_below="@+id/testButton"
            android:layout_marginTop="25dp"
            android:text="@string/hello_world" /> -->

</RelativeLayout>

initial state

color change state

Similar Question 4 (3 solutions) : AlertDialog change positive button color

Similar Question 5 (2 solutions) : Alertdialog with custom layout button

Similar Question 6 (1 solutions) : alertDialog button go to URI

Similar Question 7 (1 solutions) : Custom button in AlertDialog programmatically

Similar Question 8 (1 solutions) : Countdown in OK button of an AlertDialog

Similar Question 9 (2 solutions) : Button in AlertDialog not appearing

cc