2016-04-12 16 views
0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Some Text1" 
     android:textSize="22dp" 
     android:textStyle="bold" 
     android:textColor="@color/black" 
     android:id="@+id/header" 
     android:layout_centerHorizontal="true"/> 
    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/header" 
     android:id="@+id/list" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Some Text2" 
     android:layout_below="@id/list" 
     android:id="@+id/text" 
     /> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/image" 
     android:layout_below="@id/text" 
     /> 
</RelativeLayout> 

に表示されていない、リストビューがスクロール可能であるが、私は、リストビューの一番下までスクロールしたとき、私はTextViewにとImageViewのは、そうでないlistview.However後にレンダリングされることを期待しますリストビューはページ全体をカバーしています(上のヘッダのほかに)テキストビューとイメージビューをリストビューの下にレンダリングするにはどうすればいいですか?見解が私のレイアウトである超える相対レイアウトで

+0

相対レイアウトを線形レイアウトに変更し、各アイテムの重みを設定します。 – dex

+0

ありがとうございますが、ちょっと精巧にできますか?私は線形レイアウトで重み付けを試みましたが、リストビューはページ全体をカバーしていないので、スクロールする前にテキストと画像が表示されていました。リストビューの一番下までスクロールする前にテキストと画像を表示しないようにします。 – usry

+1

テキストと画像をフッタの最後のリストビューに表示したい場合は、フッタをlistviewに追加します。フッターはテキストと画像を含むビューのxmlになります。 –

答えて

1

それを行うには2つの方法があります。 初のLinearLayoutリストビューに重み1を使用して:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Some Text1" 
     android:textSize="22dp" 
     android:textStyle="bold" 
     android:textColor="@color/black" 
     android:id="@+id/header" 
     android:layout_centerHorizontal="true"/> 
    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:id="@+id/list" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Some Text2" 
     android:id="@+id/text" 
     /> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/image" 
     /> 
</LinearLayout> 

他RelativeLayout:

<?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="match_parent"> 

    <TextView 
     android:id="@+id/header" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:text="Some Text1" 
     android:textColor="@color/black" 
     android:textSize="22dp" 
     android:textStyle="bold" /> 

    <ListView 
     android:id="@+id/list" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/text" 
     android:layout_below="@id/header" /> 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/image" 
     android:text="Some Text2" /> 

    <ImageView 
     android:id="@+id/image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" /> 
</RelativeLayout> 

・ホープ、このことができますが。

関連する問題