简体   繁体   English

滚动视图不显示底部视图

[英]Scroll View keeps discarding the bottom View from displaying

I've created a preference UI but the thing is I can't let the bottommost child view to be displayed on the device. 我已经创建了首选项UI,但问题是我不允许最底层的子视图显示在设备上。 It keeps discarding the bottommost view. 它一直丢弃最底端的视图。 Though this query is similar to one I found in the query list yet the problem I'm facing left me with no debugging ways or I'm missing some serious property. 尽管此查询与我在查询列表中找到的查询相似,但是我面临的问题使我无法进行调试,或者缺少一些严重的属性。 My code is: The Bottom TextView which I finally wrapped inside a relativeView is the part which is discarded. 我的代码是:我最终包装在relativeView中的底部TextView是被丢弃的部分。 To ,y wonder I changed to LinearLayout from Relative built I guess It might have some issues as well.. But the most important query is that it doesn't scroll till the end of the Activity. 到了,想知道我从Relative改成了LinearLayout ,我想它可能也有一些问题。。但是最重要的查询是它直到活动结束才滚动。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Preferences">

   <RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="60dp"
       android:background="@color/colorPrimary"
       android:id="@+id/header"
enter code here
       >
       <ImageView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:id="@+id/back_key"
           />
       <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:id="@+id/text_prefer"
           android:layout_centerInParent="true"
           android:layout_centerVertical="true"
           android:text="@string/activity_name"
           android:textColor="@color/white"
           android:textStyle="bold"
           android:textSize="18sp"
           />

   </RelativeLayout>
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/wrapper_scroll"
        android:layout_below="@id/header"
        >
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/scroll_horizontal"
            android:fillViewport="true"
            >
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:layout_marginLeft="11dp"
                android:layout_marginRight="11dp"
                android:id="@+id/rel_scroll"
                android:layout_marginBottom="10dp"
                >
                <RelativeLayout

                    android:layout_width="match_parent"
                    android:layout_height="120dp"
                    android:background="@drawable/rounded_back_for_layout"
                    android:id="@+id/rel_age_layout"
                    android:layout_marginBottom="5dp"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="18dp"
                        android:id="@+id/age_text"
                        android:text="@string/age"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        android:textColor="@color/magenta_brown"
                        />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="18dp"
                        android:layout_alignParentRight="true"
                        android:text="18-26"
                        android:textStyle="bold"
                        android:textSize="14sp"
                        android:textColor="@color/black"

                        />

                </RelativeLayout>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/text_age_pref"
                    android:layout_below="@id/rel_age_layout"
                    android:text="@string/age_prefer"
                    android:textSize="10.5sp"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    />
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="45dp"
                    android:layout_below="@id/rel_age_layout"
                    android:background="@drawable/rounded_back_for_layout"
                    android:id="@+id/rel_interest_layout"
                    android:layout_marginBottom="5dp"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="16dp"
                        android:id="@+id/interested_in_text"
                        android:text="@string/interested_in"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        android:textColor="@color/magenta_brown"
                        />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="18dp"
                        android:layout_below="@id/interested_in_text"
                        android:text="@string/men"
                        android:textSize="14sp"
                        android:textColor="@color/black"
                        android:id="@+id/men"
                        />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="18dp"
                        android:layout_below="@id/men"
                        android:layout_marginTop="10dp"
                        android:text="@string/women"
                        android:textSize="14sp"
                        android:textColor="@color/black"
                        android:layout_marginBottom="10dp"
                        />
                </RelativeLayout>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/interested_pref"
                    android:layout_below="@id/rel_interest_layout"
                    android:text="@string/interested_prefer"
                    android:textSize="10.5sp"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    />

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="38dp"
                    android:layout_below="@id/rel_interest_layout"
                    android:background="@drawable/rounded_back_for_layout"
                    android:id="@+id/rel_alerts_layout"
                    android:layout_marginBottom="5dp"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="18dp"
                        android:id="@+id/alerts_mode"
                        android:text="@string/alerts"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        android:textColor="@color/magenta_brown"
                        />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="18dp"
                        android:layout_below="@id/alerts_mode"
                        android:text="@string/sound"
                        android:textSize="14sp"
                        android:layout_marginBottom="14dp"
                        android:textColor="@color/black"
                        />
                </RelativeLayout>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/sound_prefer"
                    android:layout_below="@id/rel_alerts_layout"
                    android:textSize="10.5sp"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    />
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="45dp"
                    android:layout_marginBottom="5dp"
                    android:layout_below="@id/rel_alerts_layout"
                    android:background="@drawable/rounded_back_for_layout"
                    android:id="@+id/rel_matchmaker_layout"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="18dp"
                        android:id="@+id/matchmaker_text"
                        android:text="@string/matchmaker"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        android:textColor="@color/magenta_brown"
                        />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:layout_marginLeft="18dp"
                        android:layout_below="@id/matchmaker_text"
                        android:text="@string/hide_my_prof"
                        android:textSize="14sp"
                        android:textColor="@color/black"
                        android:layout_marginBottom="10dp"

                        />
                </RelativeLayout>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/matchmaker_prefer"
                    android:text="@string/matchmaker_prefer"
                    android:layout_below="@id/rel_matchmaker_layout"
                    android:textSize="12sp"

                    />
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="38dp"
                    android:layout_below="@id/rel_matchmaker_layout"
                    android:background="@drawable/rounded_back_for_layout"
                    android:id="@+id/rel_whitelist_layout"
                    android:layout_marginBottom="10dp"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="18dp"
                        android:id="@+id/whitelist_text"
                        android:text="@string/whitelist"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        android:textColor="@color/magenta_brown"
                        />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="18dp"
                        android:layout_alignParentRight="true"
                        android:text="@string/go"
                        android:padding="10dp"
                        android:background="@drawable/edittext_rectangle_border"
                        android:textStyle="bold"
                        android:textSize="14sp"
                        android:textColor="@color/black"
                        />
                </RelativeLayout>

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/rel_whitelist_layout"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="10.5sp"
                        android:layout_marginLeft="3dp"
                        android:layout_marginRight="3dp"
                        android:text="@string/whitelist_prefer"
                        />
                </RelativeLayout>
            </LinearLayout>

        </ScrollView>

    </RelativeLayout>

    </RelativeLayout>

Here's the screenshot: 这是屏幕截图:

Try changing the height of the ScrollView from match_parent to wrap_content: 尝试将ScrollView的高度从match_parent更改为wrap_content:

<ScrollView
...
    android:layout_height="wrap_content"
... >

I tried your xml and this worked. 我尝试了您的xml,这行得通。
Add this to your last TextView 将此添加到您的最后一个TextView

android:layout_margin="18dp"   

Your last element will be: 您的最后一个元素将是:

  <RelativeLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@id/rel_whitelist_layout">
          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textSize="10.5sp"
              android:layout_marginLeft="3dp"
              android:layout_marginRight="3dp"
              android:layout_margin="18dp"  
              android:text="@string/whitelist_prefer"/>
  </RelativeLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM