在我的應用程序中,我允許用戶通過單擊「添加更多聯繫人」來添加最多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添加一個子滾動視圖。 –