我设计了一个屏幕,顶部有徽标图像视图和标题,高度约为80 dp。然后框架布局垂直保持在它旁边。框架布局动态加载片段。片段包含带有输入字段的滚动视图。问题出在这里,当焦点转到编辑文本时,整个屏幕会向上滚动。我只希望片段中的scrollview滚动。顶部区域必须固定。请仔细阅读为Holder Activity及其片段提供的布局设计。 我只想让scrollview缩小到键盘上方。任何人都可以帮助我,因为我对Android开发很新。
HolderActivity Layout
<?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"
/>
答案 0 :(得分:0)
这可能会有所帮助:
setSelectedByText:function(eID,text) {
var ele=document.getElementById(eID);
for(var ii=0; ii<ele.length; ii++)
if(ele.options[ii].text==text) { //Found!
ele.options[ii].selected=true;
return true;
}
return false;
},
在清单活动代码中使用它,如下所示:
android:windowSoftInputMode="adjustPan"
您可以在此处使用其他选项,而不是<activity
android:name=".Activity"
android:windowSoftInputMode="adjustPan" />
。