0

2つのScrollViewがあり、それぞれにTextViewが含まれています。2番目のScrollViewは通常、visibility = "gone"に設定され、ScrollViewは全画面表示されます。

上部のTextViewの脚注参照に触れると、指定された脚注がロードされ、2番目のScrollViewに正しく表示され、表示されます。この時点で、それはスクロール可能であり、うまく機能します。

ただし、読み込まれた脚注が指定されたScrollView領域よりも小さい場合は、コンテンツを表示するために必要なサイズだけにScrollViewの高さを縮小したいと思います。

何か案は?基本的に、2番目のScrollViewは、その子TextViewのコンテンツに基づいて、設定された最大サイズまでサイズ変更する必要があります。

最終的には、ユーザーがドラッグして脚注ビューのサイズを変更できるようにしたいのですが、それは後でです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
  android:orientation="horizontal">
    <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:orientation="vertical" 
        android:gravity="fill"
        android:id="@+id/contentLayout"
        android:layout_below="@id/headerLayout">
        <ScrollView 
            android:id="@+id/content_scroll"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:minHeight="200dp"  
            android:fillViewport="true"
            android:layout_below="@id/headerLayout" 
            android:layout_gravity="fill" 
            android:layout_weight="1" >
            <TextView 
                android:id="@+id/content" 
                android:text="This is the content..." 
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" />
        </ScrollView>
        <ScrollView 
            android:id="@+id/note_scroll"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:background="@android:color/background_light"
            android:layout_below="@id/content_scroll" 
            android:layout_gravity="bottom"
            android:layout_weight="2" >
            <TextView 
                android:id="@+id/note_content" 
                android:text="This is the note content..." 
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:paddingLeft="6dip"
                android:paddingRight="6dip"
                android:paddingTop="6dip"               
                android:paddingBottom="6dip"                
                android:textColor="@android:color/black"
                android:textSize="10dp"
                android:clickable="true" />
        </ScrollView>
    </LinearLayout>
</RelativeLayout>
4

1 に答える 1

0

重み属性を使用しないでください。両方のスクロール ビューから layout_weight を削除します。

また

さらに、layout_weight 属性を使用する場合は、高さを 0dip に設定します。それはうまくいきます。これらの属性の両方を一緒に使用しても意味がありません。

ありがとう

于 2011-07-23T07:04:39.493 に答える