android - 选择文本时展开带有 EditText 的对话框
问题描述
我正在尝试使用 EditText 打开自定义对话框。
该对话框起初可以正确显示,但当用户选择文本时会显示奇怪的行为。
正常状态: 在此输入图片描述
用户选择文本时的状态: 在此处输入图像描述
我的 Java 代码:
AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.AlertDialogStyle);
LayoutInflater inflater = activity.getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.dialog_edit_description, null);
builder
.setView(dialogView)
.setPositiveButton("OK", (dialogInterface, i) -> {
})
.setNegativeButton("Abbrechen", (dialogInterface, i) -> {
});
Dialog dialog = builder.create();
dialog.show();
我的布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@color/color4"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Beschreibung bearbeiten"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:textAppearance="@style/AlertDialogStyle"
android:textColor="@color/colorWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/descr_edit_text"
android:inputType="text"
android:hint="Beschreibung hinzufügen"
android:layout_width="match_parent"
android:longClickable="false"
android:layout_height="wrap_content"
android:textColorHint="@color/colorLightGrey3"
android:textColor="@color/colorWhite"
android:textAppearance="@style/myFont"
android:layout_marginTop="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="4dp" />
</LinearLayout>
解决方案
推荐阅读
- node.js - 从 node.js 应用程序访问 Kubernetes“秘密”环境变量
- c# - Xamarin iOS WebException:应用程序在 HttpWebRequest 完成后崩溃
- sql - 如何同时加入和联合
- javascript - Django Rest Framework 嵌套序列化程序创建
- ios - 使用 .xib 设计 Self-Sizing UITableViewCell,单元格不会在界面生成器中自行调整
- python - 如何用偏移量解析日期时间字符串?
- javascript - Firebase 匿名身份验证正在触发 JS if 语句的双方
- python - 从熊猫 python 网站获取文本
- react-native - 反应原生组件无法正常工作
- reactjs - JSX 回调使用旧的状态值