Android-AlertDialog按钮的统一大小

Android-AlertDialog按钮的统一大小,android,android-alertdialog,android-button,Android,Android Alertdialog,Android Button,我试图在AlertDialog中找到我的按钮。目前,一个按钮的文本进入第二行,使该按钮略大于其他两个按钮。这是我的对话(不是片段,只是在活动中) 我尝试在alert.show()之后添加此代码但它导致了崩溃 Button positive = (Button) findViewById(android.R.id.button1); positive.setLayoutParams(new LinearLayout.LayoutParams(10, 10)); Button negative =

我试图在AlertDialog中找到我的按钮。目前,一个按钮的文本进入第二行,使该按钮略大于其他两个按钮。这是我的对话(不是片段,只是在活动中)

我尝试在
alert.show()之后添加此代码但它导致了崩溃

Button positive = (Button) findViewById(android.R.id.button1);
positive.setLayoutParams(new LinearLayout.LayoutParams(10, 10));
Button negative = (Button) findViewById(android.R.id.button2);
negative.setLayoutParams(new LinearLayout.LayoutParams(10, 10));
Button neutral = (Button) findViewById(android.R.id.button3);
neutral.setLayoutParams(new LinearLayout.LayoutParams(10, 10));

最好编辑XML文件,您可以执行以下操作:

<LinearLayout
        android:id="@+id/activity_content"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

            <Button
                android:id="@+id/buttonID1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Your Button" />
            <Button
                android:id="@+id/buttonID2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Your Button" />
</LinearLayout>

我不知道该怎么处理这些东西,也不知道该把它们放在哪里。我没有一个用于AlertDialog的XML文件,当我创建一个时,所有的按钮都在说“False”。当我按程序尝试时,我仍然只是遇到了一个崩溃。如何专门引用按钮以将LayoutParams应用于它们?
<LinearLayout
        android:id="@+id/activity_content"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

            <Button
                android:id="@+id/buttonID1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Your Button" />
            <Button
                android:id="@+id/buttonID2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Your Button" />
</LinearLayout>
LinearLayout layout = (LinearLayout) findViewById(R.id.your_linear);
LayoutParams params = layout.getLayoutParams(); // Params
params.width = params.FILL_PARENT; // Fill the space horizontally
params.height = params.WRAP_CONTENT; // Fill the space vertically but "automatically", depends on the object's size.