【问题标题】:How to fix footer alignParentBottom="true" in scrollview layout如何在滚动视图布局中修复页脚 alignParentBottom="true"
【发布时间】:2019-09-10 22:46:31
【问题描述】:

当 (Linearlayout) 设置为包含它 (TextView) 的 alignParentBottom 时我遇到的问题,然后将 RelativeLayout 与滚动视图打包(这样当键盘出现时,所有视图都可以看到) - 但是,当键盘出现并且ScrollView TextView 模式与其他textview(如图片)变得不规则。

如何解决下面的问题,我希望 alignParentbottom 在滚动视图和键盘出现时有空间。

图片https://2.bp.blogspot.com/-7oX2mpmzFas/XLxdIH6x1OI/AAAAAAAAA-g/MNL4mIr_Pr85isMBc05LNTvTyQAwimmLgCLcBGAs/s1600/Graphic1.jpg

<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>

【问题讨论】:

    标签: android textview footer android-bottomnav


    【解决方案1】:

    您可以在 AndroidManifest.xml 文件中添加 android:windowSoftInputMode="adjustPan"

    为您的页脚提供 id。(android:id="@+id/footer")。并将其添加到您的活动中

    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>
    

    【讨论】:

      猜你喜欢
      • 2022-01-09
      • 1970-01-01
      • 2019-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多