相关疑难解决方法(0)

底板景观问题

在横向模式下显示底部对话框时,我的行为有误.问题发生在24. +版本的设计库中.根据下图,底片仅在横向上无法正确显示.我正在使用BottomSheetDialog类,我正在按照本教程:http://www.skholingua.com/blog/bottom-sheet-android,在我发布的应用程序中也会出现问题.

我测试了25. +版本,问题没有解决.

错误在横向24,25 +库中

在景观中出错

23. + Library中的相同示例

23. + Library中的相同示例

主要活动

public class MainActivity extends AppCompatActivity {
CoordinatorLayout coordinatorLayout;
private BottomSheetBehavior<View> mBottomSheetBehavior;
private TextView textView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_content);
    textView = (TextView) findViewById(R.id.textView);
    View bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet);

    //For your bottom sheet to be displayable, you need to create a BottomSheetBehavior.
    //This is created by getting a reference to the container view and calling BottomSheetBehavior.from() on that container.
    mBottomSheetBehavior = …
Run Code Online (Sandbox Code Playgroud)

android android-support-library android-design-library

19
推荐指数
5
解决办法
6481
查看次数

BottomSheetDialogFragment打开一半

BottomSheetDialogFragment当我打开它时,我打开一半(意思是不完全).

fragment.show(supportFragmentManager, "my_frag")
Run Code Online (Sandbox Code Playgroud)
  • 我尝试NestedScrollViewbehavior_peekHeight但没有奏效.
  • 没有尝试NestedScrollView.只有LinearLayout.
  • match_parent&之间尝试切换高度wrap_content

我有简单RecyclerViewBottomSheetDialogFragment布局.

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            ...
            >
           <android.support.v7.widget.RecyclerView
           ...
           />
Run Code Online (Sandbox Code Playgroud)

android android-layout bottom-sheet

3
推荐指数
1
解决办法
4780
查看次数

为什么底部工作表对话框无法在平板电脑上展开?

我在我的应用程序中实现了 BottomSheetDialog,但是当我将其安装在平板电脑上并将平板电脑放下时,第一次单击时它不会完全展开。它首先展开到“折叠”状态,您必须将其向上拖动才能看到所有内容。为什么要这样做?您可以根据自己的风格更改某些设置吗?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
    app:behavior_peekHeight="0dp"
    >
   ...

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
val view = layoutInflater.inflate(R.layout.home_bottom_sheet_dialog, null)
val bottomSheetDialog = BottomSheetDialog(activity!!)

bottomSheetDialog.setContentView(view)
bottomSheetDialog.show()
Run Code Online (Sandbox Code Playgroud)

我将 API 22 AndroidX 与 kotlin 结合使用。

在此输入图像描述 在此输入图像描述

android tablet android-studio bottom-sheet android-bottomsheetdialog

2
推荐指数
1
解决办法
5156
查看次数

底页不显示所有布局

例如,如何在底部工作表 kotlin 中显示所有布局,我需要像这样显示底部工作表 在此输入图像描述

但是当在呼叫底部工作表中单击时,它只显示一半

在此输入图像描述

我是 kotlin 新手,如何使用显示所有底部工作表,这是我的代码:

单击按钮时

var Bottomfragmenjemput = JemputSayaFragment()

        binding.button3.setOnClickListener {
            Bottomfragmenjemput.show(supportFragmentManager,"TAG")
        }
Run Code Online (Sandbox Code Playgroud)

这是我的 BottomsheetFragment.kt

class JemputSayaFragment : BottomSheetDialogFragment() {

    private lateinit var binding : BottomsheetlayoutBinding
    private lateinit var bottomsheet : BottomSheetBehavior<View>

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = BottomsheetlayoutBinding.inflate(inflater,container,false)

        binding.numberPicker.minValue = 1
        binding.numberPicker.maxValue = 4


        return binding.root
    }
}
Run Code Online (Sandbox Code Playgroud)

这个XML代码bottomsheetlayout.xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:padding="16dp"
    app:layout_behavior=""
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView10"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Jemput Saya"
        style="@style/TextAppearance.MaterialComponents.Headline6"
        app:layout_constraintEnd_toEndOf="parent" …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-studio

2
推荐指数
1
解决办法
3315
查看次数