• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Change AlertDialog Dimensions

AronAtVW

Newbie
Aug 7, 2014
10
0
I am using a single choice item Alert Dialog. My problem is purely cosmetic but I have all of my items in a scrollable view and I just want the Dialog to have a smaller height. I have tried to set the window layout dimensions did not do anything. Now I am trying to use a xml layout for the Dialog and that is not working either. I decided, being that it is purely cosmetic, I should ask for some advice on here as opposed to scouring the internet. Thanks in advance heres some sample code.

My Main Activity

private void boatNumDiag()
{
AlertDialog.Builder boatNumB = new AlertDialog.Builder(this);

final String[] boatNumbers = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};

ScrollView boatScroll = new ScrollView(this);

boatNumB.setTitle("Boat Number");

LayoutInflater inflater = getLayoutInflater();



boatNumB.setView(inflater.inflate(R.layout.boat_num_layout,null));

/*
boatNumB.setItems(boatNumbers, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
str += boatNumbers;
}
});
*/


boatNumB.setSingleChoiceItems(boatNumbers,-1,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i)
{

str = boatNumbers;
boatNumber.setText(str);

}
});


Dialog layout

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="40dp"
android:layout_height="40dp">

<LinearLayout
android:layout_width="40dp"
android:layout_height="40dp">


<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hey"/>


</LinearLayout>

</ScrollView>

:car::car::car:
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones