在 android 应用中展开底部 sheet 对话框
Expanding bottom sheet dialog in android app
我在底部 sheet 显示数据,按下按钮屏幕时会调用该数据。但是,sheet 上的文本多于屏幕上无法显示的文本,因此文本被剪裁了。我该如何解决这个问题,以便对话框可以滚出屏幕边缘?
我的底部布局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();
您可以将 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>
我在底部 sheet 显示数据,按下按钮屏幕时会调用该数据。但是,sheet 上的文本多于屏幕上无法显示的文本,因此文本被剪裁了。我该如何解决这个问题,以便对话框可以滚出屏幕边缘?
我的底部布局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();
您可以将 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>