2017-06-27 5 views
0

は、私は私のレイアウトを設定している:SwipeRefreshLayout +別のビュー

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <include layout="@layout/my_toolbar" /> 

    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/swipe_refresh" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <com.my.SubView 
      android:id="@+id/my_list_subview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/white" /> 
    </android.support.v4.widget.SwipeRefreshLayout> 

    <TextView 
     android:id="@+id/text_content" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="@dimen/padding_medium" 
     android:layout_margin="@dimen/padding_medium" 
     android:text="Hello" 
     android:textSize="14sp" 
     android:maxLines="3"/> 

</LinearLayout> 

問題はSwipeRefreshLayoutが画面全体を占め、TextViewにはまったく表示されないということです。

Blue line is where the textview is

テキスト・ビューである場合、上記画像における青い線です。私が行方不明のものはありますか?これは非常に単純な問題、その馬鹿だと思われる! @Tomar enter image description here

+0

layout_aboveを使用してRelativeLayoutを使用してレイアウトを下から上に構築してみてください。 –

+0

いいえ、動作しません。いずれにせよ、スワイプリフレッシュレイアウトは、スペース全体を底まで占めたいと考えています。テキストビューを上に移動すると、正しく表示されますが、下には表示されません。 – GreenBee

+0

1つのことは、親のレイアウトの高さをmatch_parentとします。 –

答えて

1

によって答えに応じて

画像2は、私は上記のように、私は以下のようにConstraintLayoutでそれを働いたこの

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

    <include layout="@layout/my_toolbar" 
     android:id="@+id/top_layout"/> 

    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/swipe_refresh" 
     android:layout_width="match_parent" 
     android:layout_above="@+id/text_content" 
     android:layout_below="@+id/top_layout" 
     android:layout_height="wrap_content"> 
     <com.my.SubView 
      android:id="@+id/my_list_subview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/white" /> 
    </android.support.v4.widget.SwipeRefreshLayout> 

    <TextView 
     android:id="@+id/text_content" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="@dimen/padding_medium" 
     android:layout_margin="@dimen/padding_medium" 
     android:text="Hello" 
     android:textSize="14sp" 
     android:layout_alignParentBottom="true" 
     android:maxLines="3"/> 

</RelativeLayout> 
+0

これは図2のように表示されます(主な質問に追加できませんコメントに追加してください)。 – GreenBee

+0

@GreenBee今すぐお試しください –

+0

ありがとうございます。 'android:layout_below =" @ + id/top_layout "を追加すると動作します!私はRelativeLayoutsを嫌いですが、明らかにLinearで動作させることはできません!実際には、ConstraintLayoutと_kind of_kludgeで作業していました。 – GreenBee

0

を試してみてください。なぜ私はテキストの上に座るためにスワイプリフレッシュレイアウトで大きなボトムマージンとパディングを使用する必要があるのか​​わかりません。これらがなければ、うまくいきません!

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/white" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 

    <include layout="@layout/toolbar" 
     android:id="@+id/my_toolbar" 
     android:layout_height="wrap_content" 
     android:layout_width="0dp" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintEnd_toEndOf="parent"/> 

    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/swipe_refresh" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="@dimen/padding_large" 
     android:paddingBottom="@dimen/padding_super_large" 
     app:layout_constraintTop_toBottomOf="@+id/my_toolbar" 
     app:layout_constraintBottom_toTopOf="@+id/text_content" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintEnd_toEndOf="parent"> 
     <com.my.SubView 
      android:id="@+id/my_list_subview" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:background="@color/white"/> 
    </android.support.v4.widget.SwipeRefreshLayout> 

    <EditText 
     android:id="@+id/text_content" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     android:hint="@string/write_message" 
     android:textSize="14sp" 
     android:maxLines="3" 
     android:padding="@dimen/padding_medium" 
     android:paddingLeft="@dimen/padding_large" 
     app:layout_constraintTop_toBottomOf="@+id/swipe_refresh" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     tools:visibility="visible" 
     tools:layout_editor_absoluteX="0dp" /> 

</android.support.constraint.ConstraintLayout> 
関連する問題