Reputation: 3544
I have created a layout in a dialog box, and need it to be scrollable so that phones with smaller screens can view the whole thing. However, when I contain the rest of my layout in a scrollview it makes it way too long with a lot of space at the bottom.
I have set the scrollview height to wrap_content, but this doesn't change anything, can anybody see any problems with my xml that would make it do this?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/allowanceroot"
android:background="@drawable/background"
>
<TextView
android:id="@+id/dialogsetminutes"
android:text="@string/setminutesallowance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="30dp"
></TextView>
<EditText
android:id="@+id/minutesinput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:inputType="number"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="30dp"
></EditText>
<TextView
android:id="@+id/dialogsetmessages"
android:text="@string/setmessagesallowance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
></TextView>
<EditText
android:id="@+id/messagesinput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:inputType="number"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="30dp"
></EditText>
<TextView
android:id="@+id/dialogsetdata"
android:text="@string/setdataallowance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
></TextView>
<EditText
android:id="@+id/datainput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:inputType="number"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
></EditText>
</LinearLayout>
</ScrollView>
Upvotes: 2
Views: 1563
Reputation: 5892
This is my code (may be useful for u )
AlertDialog.Builder builder=new AlertDialog.Builder(this);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.yourlayoutName,null);
builder.setView(layout);
builder.show();
Upvotes: 1