Skip to content Skip to sidebar Skip to footer

Android Scrollview Vertical Scrollbar Not Showing Up

So I have below layout for custom AlertDialog:

Solution 1:

I've tried to reproduce your issue and it works after some modifications. Basically I made the view lookup from the promptView.

    getWindow().setBackgroundDrawable(newColorDrawable(0));

    LayoutInflaterlayoutInflater= LayoutInflater.from(this);

    ViewpromptView= layoutInflater.inflate(
            R.layout.test, null);

    AlertDialog.BuilderalertDialogBuilder=newAlertDialog.Builder(
            this);

    alertDialogBuilder.setView(promptView);

    // create an alert dialogAlertDialogpopup= alertDialogBuilder.create();
    popup.setTitle("title");

    TextViewmessageText= (TextView) promptView.findViewById(android.R.id.message);
    TextViewpopupDate= (TextView) promptView.findViewById(R.id.popup_date);
    TextViewpopupText= (TextView) promptView.findViewById(R.id.popup_text);

    popupDate.setText("date");
    popupText.setText(longTestString);


    popup.show();

UPDATE:

I've overlooked that in my solution the scrollview pushes out the button on the bottom. It works fine if you add a layout-weight in your Scrollview. It than takes all available space and displays the bars if necessary.

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/popuplayout"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_gravity="center_vertical"android:fillViewport="true"android:orientation="vertical" ><TextViewandroid:id="@+id/popup_date"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="5dip"android:gravity="center"android:text="DateTime"android:textColor="#cccccc"android:textSize="14sp" /><Viewandroid:layout_width="match_parent"android:layout_height="1dip"android:background="#333333" /><ScrollViewandroid:id="@+id/popup_scrollview"android:layout_width="match_parent"android:layout_height="wrap_content"android:fillViewport="true"android:orientation="vertical"android:padding="10dp"android:layout_weight="0.5"><TextViewandroid:id="@+id/popup_text"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center_horizontal"android:text="Message Text"android:textColor="#FFCC00"android:textSize="18sp" /></ScrollView><Buttonandroid:id="@+id/btnSpam"android:layout_width="match_parent"android:layout_height="wrap_content"android:onClick="markSpam"android:padding="10dp"android:text="Mark as Spam" />

enter image description here

Post a Comment for "Android Scrollview Vertical Scrollbar Not Showing Up"