Question

I am trying to do ScrollView in dialog popup with this code:

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

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="40sp"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/new_realm_avatar"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_centerHorizontal="true"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/new_realm_message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/new_realm_avatar"
            android:text="long text" />
    </RelativeLayout>
 </ScrollView>

</RelativeLayout>

So when I call this in my message part and the text is bigger than the screen it becomes scrollable but hides the keys and it's height is as big as the phone screen. I want the message in the dialog to be with fixed height like I tried by wrapping the ScrollView with another layout and enforcing it height but it doesn't work that way too. So anyone has any ideas?

Was it helpful?

Solution

Try this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="40dp" >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="40dp" >

        <ImageView
            android:id="@+id/new_realm_avatar"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_centerHorizontal="true"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/new_realm_message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/new_realm_avatar"
            android:text="long text" />
    </RelativeLayout>
</ScrollView>

</RelativeLayout>

OTHER TIPS

First of all in your child RelativeLayout replace this :

android:layout_height="40sp"

with

android:layout_height="40dp"

Because sp uses for font size

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top