我设计了一个顶部带有徽标图像视图和标题的屏幕,高度约为80 dp。然后,框架布局将垂直保留在其旁边。帧布局动态加载片段。该片段包含带有输入字段的滚动视图。问题就在这里,当焦点转到编辑文本时,整个屏幕都会向上滚动。我只想滚动片段中的滚动视图。顶部区域必须固定。请仔细阅读为持有人活动及其片段提供的布局设计。我只希望滚动视图缩小到键盘上方。谁能帮我,因为我对安卓开发很陌生。
持有人活动布局
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="@+id/patternImageView"
style="@style/WFImageViewPatternBG"/>
<ImageView
android:id="@+id/titleImageView"
style="@style/WFImageViewTitle"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/fertilityTextView"
style="@style/WFTextStyleFertilityTitle"
android:layout_below="@id/titleImageView"
/>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragmentPlaceholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/fertilityTextView"
android:layout_marginTop="20dp">
<!-- Fragment will go here eventually, but it's not added in the layout -->
</FrameLayout>
片段活动布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ideasurge.winfertility.CreateAccountInputFragment">
<ScrollView
android:id="@+id/inputScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/createAcctNextBtn">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/createAcctTitleTextView"
style="@style/WFTextStyleBoldPinkTitle"
android:text="Create An Account" />
<EditText
android:id="@+id/first_name_edit_txt"
style="@style/WFEditTextStyle"
android:hint="First Name"
android:background="@drawable/rounded_border_pink"
android:layout_marginTop="20dp"
android:layout_below="@+id/createAcctTitleTextView" />
<EditText
android:id="@+id/last_name_edit_txt"
style="@style/WFEditTextStyle"
android:hint="Last Name"
android:background="@drawable/rounded_border_pink"
android:layout_below="@+id/first_name_edit_txt" />
<EditText
android:id="@+id/email_pwd_edit_txt"
style="@style/WFEditTextStyle"
android:hint="Email Address"
android:background="@drawable/rounded_border_pink"
android:layout_below="@+id/last_name_edit_txt" />
<EditText
android:id="@+id/phone_no_edit_txt"
style="@style/WFEditTextStyle"
android:hint="Phone Number"
android:background="@drawable/rounded_border_pink"
android:layout_below="@+id/email_pwd_edit_txt" />
<EditText
android:id="@+id/create_pwd_edit_txt"
style="@style/WFEditTextStyle"
android:hint="Create Password"
android:background="@drawable/rounded_border_pink"
android:layout_below="@+id/phone_no_edit_txt" />
<EditText
android:id="@+id/dob_edit_txt"
style="@style/WFEditTextStyle"
android:hint="Date of Birth"
android:background="@drawable/rounded_border_pink"
android:layout_below="@+id/create_pwd_edit_txt" />
<EditText
android:id="@+id/gender_edit_txt"
style="@style/WFEditTextStyle"
android:hint="Gender"
android:background="@drawable/rounded_border_pink"
android:layout_below="@+id/dob_edit_txt" />
<TextView
android:id="@+id/companySectionTitle"
style="@style/WFTextStyleSectionPinkTitle"
android:text="Your company may provide Fertility Benefits."
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:layout_below="@+id/gender_edit_txt"/>
<EditText
android:id="@+id/company_edit_txt"
style="@style/WFEditTextStyle"
android:hint="Name of Company"
android:background="@drawable/rounded_border_pink"
android:layout_below="@+id/companySectionTitle" />
<EditText
android:id="@+id/insurance_id_edit_txt"
style="@style/WFEditTextStyle"
android:hint="Insurance Subscriber ID"
android:background="@drawable/rounded_border_pink"
android:layout_below="@+id/company_edit_txt" />
</RelativeLayout>
</ScrollView>
<Button
android:id="@+id/createAcctNextBtn"
style="@style/WFButtonStylePink"
android:text="NEXT"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_alignParentBottom="true"
/>
这可能会有所帮助:
android:windowSoftInputMode="adjustPan"
在清单活动标记中使用它,如下所示:
<activity
android:name=".Activity"
android:windowSoftInputMode="adjustPan" />
在这里,您可以使用其他选项而不是adjustpan
.