[英]Android soft keyboard doesn't scroll and covers EditText when Window flag “LayoutNoLimits” is set
我希望我的漸變背景在狀態欄下方擴展。 我可以通過將狀態欄顏色設置為透明,然后調用:
Window.AddFlags(WindowManagerFlags.LayoutNoLimits);
但是,設置WindowManagerFlags.LayoutNoLimits
阻止軟鍵盤向上滾動屏幕,並且正在編輯的EditText視圖將隱藏在鍵盤下方。
我建議你可以使用另一種方法在狀態欄下擴展漸變背景。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:background="@drawable/gradient">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#fff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true">
<LinearLayout
android:fitsSystemWindows="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:layout_marginBottom="10dp">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/check">
</ImageButton>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/uncheck">
</ImageButton>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/icaon">
</ImageButton>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "11111111"/>
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:imeOptions="actionGo"
android:inputType="text"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
梯度:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="135" android:startColor="#f56f2c" android:endColor="#fa9f46"/>
</shape>
protected override void OnCreate(Bundle savedInstanceState)
{
if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Kitkat)
{
Window w = Window;
w.AddFlags(WindowManagerFlags.TranslucentStatus);
w.SetSoftInputMode(SoftInput.StateHidden | SoftInput.AdjustPan);
}
// Set our view from the "main" layout resource
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.layout2);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.