如何解决无法在软键盘上方显示 bottomSheetDialogFragment
我正在使用与软输入键盘重叠的 BottomSheetDialogFragment
,因此我从这里尝试了许多现有的答案。像this。但没有什么对我有用。我希望整个布局显示在键盘上方或仅显示编辑文本。
这是我在 XML 文件中的设计结构。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center_horizontal"
android:orientation="vertical"
android:id="@+id/bottomSheetRoot"
android:background="@android:color/transparent"
tools:context=".fragments.JoinTeamFragment"
app:layout_behavior="@string/bottom_sheet_behavior">
<androidx.cardview.widget.CardView>
<androidx.core.widget.nestedScrollView>
<LinearLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/join_dialog_description"/>
<androidx.cardview.widget.CardView>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/msg_from_author_tv"/>
</androidx.cardview.widget.CardView>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/join_dialog_instruction_msg"/>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/message_et_join_team"
android:lines="5" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/join_message_tv_counter"/>
<LinearLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/cancel_button_join"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/confirm_button_join"/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.nestedScrollView>
</androidx.cardview.widget.CardView>
</LinearLayout>
还有kt班
class JoinTeamFragment : BottomSheetDialogFragment() {
private var mListener: BottomSheetListener? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_norMAL,R.style.CustomBottomSheetDialogTheme)
}
override fun onCreateView(inflater: LayoutInflater,container: ViewGroup?,savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_join_team,container,false)
{
}
interface BottomSheetListener
override fun onAttach(context:Context) {
super.onAttach(context)
try
{
mListener = context as BottomSheetListener
}
catch (e:ClassCastException) {
throw ClassCastException(("$context must implement BottomSheetListener"))
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。