2016-12-04 4 views
1

私は線形レイアウトとテキストビュー(両方ともスクロールビューでラップ)を持っています。私は最初に画面の下部にテキストビューを配置したい(私はそれを下部に固定する必要はありません)。私はこの質問に続きましたAdding view to bottom of layout inside a scrollview しかしそれは役に立たなかった。ここに私のレイアウトです。 (すべてのlayout_width属性はmatch_parentです)スクロールビューのレイアウトの一番下にビューを追加する

<ScrollView 
android:layout_height="match_parent" 
android:fillViewport="true"> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_height="wrap_content"> 
    <LinearLayout 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
     <!-- this expands to fill the empty space if needed --> 
    </LinearLayout> 

    <!-- this sits at the bottom of the ScrollView, 
    getting pushed out of view if the ScrollView's 
    content is tall enough --> 
    <TextView 
     android:layout_height="wrap_content" 
     android:text="something"> 
    </TextView> 
</LinearLayout> 
</ScrollView> 

問題はtextviewが決して見えないことです。私はそれを修正するために何ができるのか教えていただけますか? (最初は、線形レイアウトとテキストビューが画面に収まるのに十分なスペースがあります) PS:他のすべての関連する質問は、テキストビューを一番下に固定したいので、重複としてマークしてください。

+0

この画面のどの部分あなたがスクロールすることを期待しない場合に置かれた場合のTextViewで最後の項目底? – foxanna

+0

スクロールするには画面全体が必要です。私は線形レイアウトでテキストを編集しています。その上でクリックするとソフトキーボードが開きますので、画面のスクロールが必要です。テキストビューは、下部にのみ最初に置く必要があります – Jacksparrow

+0

Activity.javaファイル内のレイアウトファイルからビューを膨張させ、scrollViewでaddViewメソッドを使用してみます。わからないtho – Asym

答えて

1

この1

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="10" 
     android:fillViewport="true"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="something"> 
      </TextView> 
     </LinearLayout> 

    </ScrollView> 

    <include 
     layout="@layout/your_edit_text_layout_here" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" /> 
</LinearLayout> 
+0

これはどちらも動作しません – Jacksparrow

+0

このanwserのコピー... http://stackoverflow.com/a/4258531/3678308 ... –

+0

上記のコードを試してみてください。あなたの要件を満たすかもしれません。 –

0

がthis.Itはあなたの問題を解決することがあります試してみ

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


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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 


       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="text1" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="text2" /> 


      </LinearLayout> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="something"></TextView> 
     </LinearLayout> 

    </ScrollView> 
</RelativeLayout> 
関連する問題