我的AlertDialog出现问题,我有一个recyclerView和searchView。
当我按下searchView时,它会从recyclerView中拉伸物品一会儿,我会避免这种情况。
我认为问题在于,当我按屏幕上看到的searchView时,它会将alertDialog移动到比原始位置高一点的位置,但是我无法解决该问题,这是我的RecyclerView xml和带有AlertDialog的xml
recyclerView项目xml:
static void Main(string[] args)
{
string input = "this is a test AAA one more test adakljd jaklsdj BBB sakldjasdkj CCC";
string [] pattern = {"AAA", "BBB","CCC"};
string replacement = "XXX";
string result = null;
for (int i = 0; i < pattern.Length; i++)
{
result = Regex.Replace(input, pattern[i], replacement);
}
Console.WriteLine(result);
}
这是带有AlertDialog的xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="2dp">
<TextView
android:id="@+id/Desc"
style="@style/word_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="5"
android:gravity="center_vertical"
android:maxLines="1"
android:scrollHorizontally="true"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/line"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/PrePiu"
style="@style/word_title"
android:layout_marginTop="2dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAlignment="textEnd"
android:textSize="10sp"
tools:ignore="SmallSp" />
<TextView
android:id="@+id/PreMeno"
style="@style/word_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="2dp"
android:textAlignment="textEnd"
android:textSize="10sp"
tools:ignore="SmallSp" />
</LinearLayout>
</LinearLayout>
答案 0 :(得分:0)
通过在创建AlertDialog之后添加以下代码来解决
Objects.requireNonNull(dialog.getWindow()).setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
对话框是AlertDialog对象。