在我的应用程序中,我允许用户通过单击“添加更多联系人”来添加最多5 EditText
视图。但是当出现EditText
视图时,布局垂直下降。所以我想为EditText
视图放置一个ScrollView
而不是Button
。我尝试但每次都失败。有人可以请帮助。滚动视图Android故障
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mLayout"
android:layout_width="match_parent"
android:layout_height="237dp"
android:orientation="vertical"
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" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="236dp" >
<EditText
android:id="@+id/edittext"
android:layout_width="298dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="@string/et_display" >
<requestFocus />
</EditText>
</ScrollView>
<Button
android:id="@+id/bpickperson"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="169dp"
android:text="@string/b_pick" />
<Button
android:id="@+id/balert"
android:layout_width="288dp"
android:layout_height="wrap_content"
android:text="@string/b_alert" />
<Button
android:id="@+id/baddmorecontacts"
android:layout_width="288dp"
android:layout_height="wrap_content"
android:text="@string/b_addmorecontacts" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/b_facebook"
android:layout_width="144dp"
android:layout_height="fill_parent"
android:text="@string/b_facebook" />
<Button
android:id="@+id/b_twitter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/b_twitter" />
</LinearLayout>
你能不能给一些代码,你编程添加'EditTexts',并通过'失败everytime'究竟是什么实际效果? –
这里没有你的.xml中使用的滚动视图。 – Umitk
@bhanu:我没有看到任何'ScrollView'。您需要为您的LinearLayout添加一个子滚动视图。 –