Как исправить нижний колонтитул alignParentBottom=true в макете прокрутки

Проблема, с которой я столкнулся, когда (Linearlayout) был установлен на alignParentBottom, который содержал его (TextView), а затем упаковал RelativeLayout с прокруткой (чтобы при появлении клавиатуры можно было увидеть все виды) - однако, когда появляется клавиатура и режим ScrollView 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>

person vhlan.com    schedule 21.04.2019    source источник


Ответы (1)


Вы можете добавить android:windowSoftInputMode="adjustPan" в свой файл AndroidManifest.xml.

Дайте идентификатор вашему нижнему колонтитулу (android:id="@+id/footer"). И добавьте это в свою деятельность

LinearLayout footer = (EditText) findViewById(R.id.footer);

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextSearch.getWindowToken(), 0);

Если это не сработает, вы должны обернуть свой ScrollView с помощью RelativeLayout

<RelativeLayout>
   <ScrollView>
       ......
   </ScrollView>
</RelativeLayout>
person Beyazid    schedule 21.04.2019