문제

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?

도움이 되었습니까?

해결책

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>

다른 팁

First of all in your child RelativeLayout replace this :

android:layout_height="40sp"

with

android:layout_height="40dp"

Because sp uses for font size

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top