2016-07-25 2 views
0

私のScrollViewに問題があります。私は利用可能なスペースの中にそれを取り入れたいが、私はどのように知っているのではない。Androidで利用可能なスペースにスクロールビューを合わせる

今、私は1つのLinearLayout前に私のScrollViewと私のTextViewを持っている:

 <ScrollView 
     android:id="@+id/scrollView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:fillViewport="true" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/previousimage" 
     android:layout_marginTop="@dimen/margin"> 


     <TextView 
      android:id="@+id/question_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="@dimen/margintop" 
      android:gravity="center_horizontal" 
      android:paddingBottom="@dimen/margin_five" 
      android:scrollbars="vertical" 
      android:textColor="@color/white" 
      android:textSize="@dimen/common_textsize" /> 

    </ScrollView> 
    <LinearLayout 
     android:id="@+id/bottom_options" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_below="@+id/scrollView" 
     android:layout_marginTop="@dimen/margin_small" 
     android:gravity="center|bottom" 
     android:orientation="vertical"> 

問題は、私は私のTextViewの内側にそんなにテキストを持っている場合のLinearLayoutがダウンして行くと、それはテキストをスクロールしたいhides.Iということです内部。 LinearLayoutを押し下げることなく。

このスペースをScrollViewですべての画面サイズに自動的に適応させたいと思っています。

See the image Layaout

ありがとうございます!

+0

私はあなたの線形レイアウトがここに無用だと思います。 –

+0

こんにちは、これをチェックしてください。 http://stackoverflow.com/questions/1748977/making-textview-scrollable-in-android – PSone

答えて

2

ScrollViewの前にLinearLayoutを定義し、ScrollViewをLinearLayout、match_parentより上に設定します。このように:

<LinearLayout 
    android:id="@+id/bottom_options" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_marginTop="@dimen/margin_small" 
    android:gravity="center|bottom" 
    android:orientation="vertical"> 
    ... 
</LinearLayout> 

<ScrollView 
    android:id="@+id/scrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:fillViewport="true" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/previousimage" 
    android:layout_above="@+id/bottom_options" 
    android:layout_marginTop="@dimen/margin"> 

    <TextView 
     android:id="@+id/question_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/margintop" 
     android:gravity="center_horizontal" 
     android:paddingBottom="@dimen/margin_five" 
     android:scrollbars="vertical" 
     android:textColor="@color/white" 
     android:textSize="@dimen/common_textsize" /> 

</ScrollView> 
+0

ありがとう!この完璧な仕事!今私は "TextView"と内部のテキストに問題があります。一番下にテキストが表示され、ScrollViewの中央に表示したいと思っています。 – user3777879

+0

ScrollViewとTextViewの両方に「android:layout_marginTop」があります。私はそれが複製されていると思うので、テキストは下に行く。また、テキストを "center_horizo​​ntal"にしたい場合は、android:layout_widthを "match_parent"に変更する必要があります。 –

+0

完璧!作品:) – user3777879

0

ScrollViewは常にmatch_parent(または少なくとも使用可能なスペースよりも小さい)にする必要があります。それ以外の場合は、子どもと同じスペースを使用するため、子どもがいないのでスクロールする必要はありません。

+0

ScrollViewで私のセットアップは、この場合:アンドロイド:layout_width = "match_parent" アンドロイド:layout_heightは= "match_parent" その後のLinearLayoutを完全に非表示になります。 – user3777879

+0

あなたの線形レイアウトは空ですので、その高さは0になります.ScrollViewの下にLinearLayoutを表示する必要がある場合は、それらを親のレイアウトに埋め込む必要があります。 –

+0

LinearLayoutは塗りつぶされていますが、コンテンツを貼り付けていません。今私はこれを持っています。 http://i.stack.imgur.com/zo04x.png しかし、もし私がテキストをたくさん持っていれば。 ScrollViewは機能せず、LinearLayoutを画面の外に押します。 – user3777879

関連する問題