Paul Lee
Paul Lee

Reputation: 25

Expanding bottom sheet dialog in android app

I'm displaying data on a bottom sheet which is invoked when a button screen is pressed. However, there is more text on the sheet than can be shown on screen, and as a result, the text is clipped. How can I fix this so that dialog can be scrolled off the edge of the screen?

My bottom layout xml files is as follows:

<?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>

and I'm summoning it with the following code:

 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();

Upvotes: 0

Views: 772

Answers (1)

Mehrbod Khiabani
Mehrbod Khiabani

Reputation: 543

You can put your TextView inside a ScrollView. Your code should look like this:

<?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>

Upvotes: 1

Related Questions