嗨,我是Android的新手,我无法理解为什么会这样。我无法滚动我的滚动视图。它有一个textView,一个imageview和几个线性布局,我的代码在
下面请一位有人帮助我
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"
android:theme="@style/Content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:scrollbars="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/enter_basicinformation_title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:layout_weight="2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinState"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
app:ms_arrowColor="@color/text_hint_color"
app:ms_arrowSize="16dp"
app:ms_floatingLabelColor="@color/text_hint_color"
app:ms_floatingLabelText="@string/sir_name_title"
app:ms_highlightColor="@color/colorAccent"
app:ms_hint="@string/sir_name_title"
app:ms_multiline="true" />
</RelativeLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/username_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/username_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:nextFocusDown="@+id/lastname_id" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/lastname_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/last_name_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:nextFocusDown="@+id/email_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/email_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/email_id_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:nextFocusDown="@+id/re_email_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/re_email_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/re_email_id_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/password_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/password_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:nextFocusDown="@+id/re_password_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/re_password_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/re_reenter_password_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/register_button_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="@string/register_title"
android:theme="@style/greenColorButton" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="25dp"
android:text="@string/existing_user_title" />
</LinearLayout>
</ScrollView>
答案 0 :(得分:0)
// Make parent layout scroll and put linear layout inside .
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:scrollbars="vertical" >
...
...
</LinearLayout>
</ScrollView>
答案 1 :(得分:0)
试试这个: 我删除了@ style / content,稍后再添加。其余的修改就像我在评论中告诉你的那样
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="@android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:animateLayoutChanges="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/enter_basicinformation_title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:layout_weight="2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinState"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
app:ms_arrowColor="@color/text_hint_color"
app:ms_arrowSize="16dp"
app:ms_floatingLabelColor="@color/text_hint_color"
app:ms_floatingLabelText="@string/sir_name_title"
app:ms_highlightColor="@color/colorAccent"
app:ms_hint="@string/sir_name_title"
app:ms_multiline="true" />
</RelativeLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/username_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/username_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:nextFocusDown="@+id/lastname_id" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/lastname_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/last_name_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:nextFocusDown="@+id/email_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/email_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/email_id_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:nextFocusDown="@+id/re_email_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/re_email_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/re_email_id_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/edit_text_margin_top"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/password_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/password_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:nextFocusDown="@+id/re_password_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextFieldInputLayout">
<EditText
android:id="@+id/re_password_id"
style="@style/MaterialDesignEditTextStyle"
android:drawablePadding="10dp"
android:hint="@string/re_reenter_password_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/register_button_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="@string/register_title"
android:theme="@style/greenColorButton" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="25dp"
android:text="@string/existing_user_title" />
</LinearLayout>
</ScrollView>
</FrameLayout>