如何在滚动视图布局中修复页脚 alignParentBottom="true"
How to fix footer alignParentBottom="true" in scrollview layout
当 (Linearlayout) 设置为包含它 (TextView) 的 alignParentBottom 然后将 RelativeLayout 与 scrollview 打包时我遇到的问题(以便当键盘出现时可以看到所有视图) - 但是,当键盘出现时并且 ScrollView TextView 模式与其他 textview(例如图片)变得不规则。
如何解决下面我的问题,我希望 alignParentbottom 在滚动视图和键盘出现时具有 space。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/badan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:gravity="center_vertical"
android:padding="20dp">
<!-- Header Starts-->
<LinearLayout android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:layout_marginTop="50dp"
android:layout_marginBottom="15dp"
android:gravity="center"
android:paddingBottom="5dip">
<!-- Logo Start-->
<ImageView android:src="@drawable/logo"
android:layout_width="100dp"
android:layout_height="100dp"/>
<!-- Logo Ends -->
</LinearLayout>
<!-- Header Ends -->
<!-- Login Form -->
<LinearLayout
android:id="@+id/loginform"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:layout_below="@id/header">
<!-- Email Label -->
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:padding="10dp"
android:background="@drawable/forminput"
android:inputType="textEmailAddress"
android:singleLine="true"
android:hint="Email" />
<!-- Password Label -->
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="10dp"
android:background="@drawable/forminput"
android:singleLine="true"
android:inputType="textPassword"
android:hint="Kata Sandi"/>
<!-- Login button -->
<Button android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/button"
android:text="Login"
android:textColor="@color/white"
android:textSize="17dp"/>
<!-- Link to Registration Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lupa detail informasi masuk Anda? Dapatkan bantuan untuk masuk."
android:textSize="14sp"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<!-- Login Form Ends -->
<!-- Footer Start-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:gravity="center"
android:layout_height="wrap_content"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tidak punya akun?"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Buat akun."
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<!-- Footer Ends -->
</RelativeLayout>
</ScrollView>
您可以在 AndroidManifest.xml 文件中添加 android:windowSoftInputMode="adjustPan"
为您的页脚提供 ID。(android:id="@+id/footer")。然后将其添加到 activity
LinearLayout footer = (EditText) findViewById(R.id.footer);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextSearch.getWindowToken(), 0);
如果它不起作用,你应该用 RelativeLayout 包裹你的 ScrollView
<RelativeLayout>
<ScrollView>
......
</ScrollView>
</RelativeLayout>
当 (Linearlayout) 设置为包含它 (TextView) 的 alignParentBottom 然后将 RelativeLayout 与 scrollview 打包时我遇到的问题(以便当键盘出现时可以看到所有视图) - 但是,当键盘出现时并且 ScrollView TextView 模式与其他 textview(例如图片)变得不规则。
如何解决下面我的问题,我希望 alignParentbottom 在滚动视图和键盘出现时具有 space。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/badan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:gravity="center_vertical"
android:padding="20dp">
<!-- Header Starts-->
<LinearLayout android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:layout_marginTop="50dp"
android:layout_marginBottom="15dp"
android:gravity="center"
android:paddingBottom="5dip">
<!-- Logo Start-->
<ImageView android:src="@drawable/logo"
android:layout_width="100dp"
android:layout_height="100dp"/>
<!-- Logo Ends -->
</LinearLayout>
<!-- Header Ends -->
<!-- Login Form -->
<LinearLayout
android:id="@+id/loginform"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:layout_below="@id/header">
<!-- Email Label -->
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:padding="10dp"
android:background="@drawable/forminput"
android:inputType="textEmailAddress"
android:singleLine="true"
android:hint="Email" />
<!-- Password Label -->
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="10dp"
android:background="@drawable/forminput"
android:singleLine="true"
android:inputType="textPassword"
android:hint="Kata Sandi"/>
<!-- Login button -->
<Button android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/button"
android:text="Login"
android:textColor="@color/white"
android:textSize="17dp"/>
<!-- Link to Registration Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lupa detail informasi masuk Anda? Dapatkan bantuan untuk masuk."
android:textSize="14sp"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<!-- Login Form Ends -->
<!-- Footer Start-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:gravity="center"
android:layout_height="wrap_content"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tidak punya akun?"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Buat akun."
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<!-- Footer Ends -->
</RelativeLayout>
</ScrollView>
您可以在 AndroidManifest.xml 文件中添加 android:windowSoftInputMode="adjustPan"
为您的页脚提供 ID。(android:id="@+id/footer")。然后将其添加到 activity
LinearLayout footer = (EditText) findViewById(R.id.footer);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextSearch.getWindowToken(), 0);
如果它不起作用,你应该用 RelativeLayout 包裹你的 ScrollView
<RelativeLayout>
<ScrollView>
......
</ScrollView>
</RelativeLayout>