【问题标题】:Expanding bottom sheet dialog in android app在android应用程序中扩展底部工作表对话框
【发布时间】:2019-06-27 11:07:15
【问题描述】:

我在按下按钮屏幕时调用的底部工作表上显示数据。但是,工作表上的文本比屏幕上显示的要多,因此,文本被剪裁了。我该如何解决这个问题,以便对话框可以滚动到屏幕边缘?

我的底部布局xml文件如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:text=""
    android:id="@+id/splo"
    />

</LinearLayout>

我用以下代码召唤它:

 BottomSheetDialog dialog = new BottomSheetDialog(this);

    View view = getLayoutInflater().inflate(R.layout.fragment_bottom_layout, null);

    dialog.setContentView( view );

    TextView tv = (TextView) view.findViewById( R.id.splo);
    tv.setText( sp );

    dialog.show();

【问题讨论】:

    标签: android bottom-sheet


    【解决方案1】:

    您可以将TextView 放入ScrollView。您的代码应如下所示:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text=""
        android:id="@+id/splo"
        />
    </ScrollView>
    
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-19
      • 2022-01-20
      • 2020-05-15
      • 2021-12-02
      • 2016-10-17
      • 2012-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多