2016-08-25 8 views
0

TextViewは特定のレイアウトの中にあります。このレイアウトのヘッダーレイアウトには、折りたたみツールバーがあります。したがって、折りたたみツールバーはメインレイアウトであり、コンテンツレイアウトの内部にはTextViewがあります。しかし、TextViewの内容はかなりあり、CollapsingToolbarが崩壊すると切り取られます。 TextViewをスクロール可能にするにはどうすればよいですか?スクロール可能にしたいTextViewはtxtEventDescriptionと呼ばれます。次のように私のコンテンツのXMLは次のとおりです。ツールバーのスクロールバーを使用してコンテンツレイアウト内でテキストビューを作成する方法

<?xml version="1.0" encoding="utf-8"?> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Price" 
    android:id="@+id/txtEventPrice" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:text="Date" 
    android:id="@+id/txtEventDate" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" /> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Event Description" 
    android:id="@+id/txtEventDescription" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_below="@+id/txtEventPrice" 
    android:layout_marginTop="20dp" 
    android:layout_centerHorizontal="true" /> 

答えて

0

私はちょうどScrollViewのレイアウトコントローラ内の最後のテキストビューをカプセル化します。 ScrollViewの高さと位置を必要に応じて制限し、内部にテキストを含めます。私は例を作るためにあなたのXMLを使用した:

<ScrollView 
    android:layout_width="wrap_content" 
    android:layout_height="15dp" 
    android:id="@+id/scrollView" 
    android:layout_below="@+id/txtEventPrice" 
    android:layout_marginTop="20dp" 
    android:layout_alignBottom="@+id/txtEventDescription" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Event Description a big long list of event description things a really really long list that takes up three lines" 
     android:id="@+id/txtEventDescription" 
     android:textAppearance="?android:attr/textAppearanceMedium" 

     android:layout_centerHorizontal="true" /> 

</ScrollView> 
+0

完璧にちょうどそれに応じてlayout_heightを調整する必要があります – Manny265

関連する問題