我在使用ScrollView时遇到问题.出于某种奇怪的原因,它隐藏了要显示在顶部的内容.我试着给予保证金,填充等,但似乎没有任何效果.这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:background="@drawable/background">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="@drawable/titlebar"
android:id="@+id/titlebar">
<TextView android:layout_width="fill_parent" android:id="@+id/textView1"
android:layout_height="fill_parent" android:layout_gravity="center"
android:gravity="center" android:textColor="@color/white"
android:textSize="20dip" android:text="Help"></TextView>
</LinearLayout>
<ScrollView android:layout_height="wrap_content" android:id="@+id/scrollView1"
android:layout_width="fill_parent">
<LinearLayout android:orientation="vertical" android:id="@+id/linearLayout2"
android:gravity="center" android:layout_width="fill_parent"
android:layout_gravity="center" android:layout_height="fill_parent"
android:paddingLeft="10dip" android:paddingRight="5dip">
<ImageView android:layout_height="wrap_content"
android:src="@drawable/icon" android:layout_marginTop="10dip"
android:id="@+id/help_icon" android:layout_width="fill_parent"
android:layout_marginBottom="15dip"></ImageView>
<TextView android:layout_height="wrap_content"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed dapibus venenatis suscipit.\n\nCras lacus sem, cursus a dictum sed, condimentum quis urna. Ut vel metus lorem, quis semper lacus. Suspendisse eu urna massa, a …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用ScrollView和Toolbar作为LinearLayout的唯一子项,但它们相互重叠.搜索了一下,但没有找到任何有用的,任何想法如何解决这个而不是给ScrollView填充/边距?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:float="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="right"
android:background="@color/white_dark_50">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"
android:theme="@style/AppTheme"
android:scrollbarStyle="outsideOverlay"
android:gravity="center_vertical|right"
android:layout_alignParentTop="true"
android:background="@color/colorPrimary"
>
<!-- -->
</android.support.v7.widget.Toolbar>
<ScrollView
android:scrollbarStyle="outsideOverlay"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="center"
android:background="@color/white_dark_50" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="right"
android:background="@color/white_dark_50">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="????? ???? ????"
android:id="@+id/new_sentence_title"
android:textColor="@color/midnight_blue"
android:layout_margin="10dp"
android:textStyle="bold"
android:gravity="center_vertical"
android:drawableRight="@drawable/ic_colored_doll"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginLeft="25dp"
android:layerType="software"
android:layout_marginRight="25dp"
android:background="@drawable/dashed_line" />
<com.wrapp.floatlabelededittext.FloatLabeledEditTextRightSided
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="5dp"
float:fletPaddingLeft="10dp"
float:fletPaddingRight="10dp"
android:id="@+id/new_sentence_name"
float:fletPadding="10dp">
<EditText
android:layout_marginLeft="10dp"
android:id="@+id/new_sentence_name_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme" …Run Code Online (Sandbox Code Playgroud) 在您将其标记为重复之前,让我告诉您,我已经搜索了所有答案,但都是徒劳的。
我使用Tabs带Actionbar。
我已经设置android:layout_height="match_parent"的ScrollView,如许多解决方案建议。
我还android:layout_gravity="center"按照以下建议从所有布局中删除了:
Android scrollview隐藏布局中的顶部内容
我也定了,android:fillViewport="true"但是没有运气。
我还缺少其他任何技巧吗?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<CalendarView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/calendarView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Guest"/>
<NumberPicker
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</NumberPicker>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_time_slot"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_add_on"/>
<Button
android:id="@+id/btn_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_btn_confirm"/>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是活动的xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.squincy.wspace.ui.HomeActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar" …Run Code Online (Sandbox Code Playgroud)