如何在对话框活动中设置scrollview

时间:2015-06-24 21:24:59

标签: android android-activity dialog

我希望我的对话框活动滚动其中的视图。我在其中使用了几个编辑文本。在布局中添加更多项目会增加对话框活动的大小。这是我不想要的。下面是我的对话框活动的xml文件

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" >
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android" >


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:weightSum="100"
    android:background="@drawable/bg_offer_coffee"
    android:padding="10dp"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:hint="Enter Name"
        android:gravity="center"
        android:ems="10"
        android:id="@+id/et_name"
        android:layout_marginTop="50dp"/>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="10"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress"
        android:ems="10"
        android:id="@+id/et_email"
        android:hint="Enter Email"
        android:gravity="center"
        android:layout_gravity="center_horizontal" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="10"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="phone"
        android:gravity="center"
        android:hint="Enter contact_number"
        android:ems="10"
        android:id="@+id/et_contact" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="10"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPostalAddress"
        android:ems="10"
        android:gravity="center"
        android:hint="Enter Address"
        android:id="@+id/et_address" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="10"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_coffee_brand"
        android:hint="Enter Coffee Brand"
        android:gravity="center"/>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="10"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_num_person1"
        android:hint="Enter Num Of Person"
        android:gravity="center"/>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="10"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_num_person2"
        android:hint="Enter Num Of Person"
        android:gravity="center"/>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="10"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_num_person3"
        android:hint="Enter Num Of Person"
        android:gravity="center"/>

</LinearLayout>
</ScrollView>
    </LinearLayout>

请告诉我如何做到这一点,我尝试了很多链接,但没有什么对我有用。请帮助

0 个答案:

没有答案