ScrollView 在我的视图中不起作用
ScrollView not working in my view
我想让我的视图可以滚动,但它不起作用。我检查过但找不到问题。然而,滚动视图在屏幕的某些部分可见,但最后一个按钮从未显示。
这是代码:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/margin_default"
android:background="@color/ThemeColor"
tools:context=".AuthActivityFragment"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@mipmap/logo_large"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@mipmap/login_form_bg"
android:padding="20dp"
android:gravity="center"
android:layout_margin="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/heading_login"
android:layout_gravity="center"
android:textColor="@color/black_shade"
style="@android:style/TextAppearance.DeviceDefault.Medium"
android:textStyle="bold"
/>
<EditText android:hint="@string/hint_login_username"
android:id="@+id/etEmail"
android:textColorHint="@color/light_grey_hint"
android:singleLine="true"
android:inputType="textEmailAddress"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="@dimen/margin_default"
android:background="@drawable/border_fields"
style="@android:style/TextAppearance.DeviceDefault.Medium"
android:paddingBottom="@dimen/margin_default"
android:paddingTop="@dimen/margin_default"
android:paddingLeft="@dimen/large_margins"
android:paddingRight="@dimen/large_margins"
/>
<EditText android:hint="@string/hint_login_password"
android:id="@+id/etPassword"
android:textColorHint="@color/light_grey_hint"
android:singleLine="true"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/border_fields"
style="@android:style/TextAppearance.DeviceDefault.Medium"
android:paddingBottom="@dimen/margin_default"
android:paddingTop="@dimen/margin_default"
android:paddingLeft="@dimen/large_margins"
android:paddingRight="@dimen/large_margins"
android:layout_margin="@dimen/margin_default"
android:inputType="textPassword"
android:ems="10"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:padding="@dimen/margin_default"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_small_cross"
android:layout_gravity="center_vertical"
android:padding="@dimen/large_margins"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_small_cross"
android:layout_gravity="center_vertical"
android:padding="@dimen/large_margins"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnLogin"
android:background="@mipmap/login"
android:layout_marginRight="@dimen/margin_default"
android:layout_gravity="center_vertical"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_small_cross"
android:padding="@dimen/large_margins"
android:layout_gravity="center_vertical"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_small_cross"
android:padding="@dimen/large_margins"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
</LinearLayout>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSignUp"
android:background="@mipmap/signup"
android:layout_marginRight="@dimen/margin_default"
android:layout_gravity="center_horizontal"
/>
</LinearLayout>
</ScrollView>
再添加一个 LinearLayout
包含所有其他 LinearLayouts
勾选Doc
A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects.
ScrollView 一切正常。
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"<br>
这段代码是你的祸害。因为你给第一个 child 留了余地,它没有显示完整的 content.Change 它给
android:paddingBottom="32dp"
android:paddingTop="32dp"
我想让我的视图可以滚动,但它不起作用。我检查过但找不到问题。然而,滚动视图在屏幕的某些部分可见,但最后一个按钮从未显示。
这是代码:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/margin_default"
android:background="@color/ThemeColor"
tools:context=".AuthActivityFragment"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@mipmap/logo_large"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@mipmap/login_form_bg"
android:padding="20dp"
android:gravity="center"
android:layout_margin="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/heading_login"
android:layout_gravity="center"
android:textColor="@color/black_shade"
style="@android:style/TextAppearance.DeviceDefault.Medium"
android:textStyle="bold"
/>
<EditText android:hint="@string/hint_login_username"
android:id="@+id/etEmail"
android:textColorHint="@color/light_grey_hint"
android:singleLine="true"
android:inputType="textEmailAddress"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="@dimen/margin_default"
android:background="@drawable/border_fields"
style="@android:style/TextAppearance.DeviceDefault.Medium"
android:paddingBottom="@dimen/margin_default"
android:paddingTop="@dimen/margin_default"
android:paddingLeft="@dimen/large_margins"
android:paddingRight="@dimen/large_margins"
/>
<EditText android:hint="@string/hint_login_password"
android:id="@+id/etPassword"
android:textColorHint="@color/light_grey_hint"
android:singleLine="true"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/border_fields"
style="@android:style/TextAppearance.DeviceDefault.Medium"
android:paddingBottom="@dimen/margin_default"
android:paddingTop="@dimen/margin_default"
android:paddingLeft="@dimen/large_margins"
android:paddingRight="@dimen/large_margins"
android:layout_margin="@dimen/margin_default"
android:inputType="textPassword"
android:ems="10"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:padding="@dimen/margin_default"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_small_cross"
android:layout_gravity="center_vertical"
android:padding="@dimen/large_margins"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_small_cross"
android:layout_gravity="center_vertical"
android:padding="@dimen/large_margins"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnLogin"
android:background="@mipmap/login"
android:layout_marginRight="@dimen/margin_default"
android:layout_gravity="center_vertical"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_small_cross"
android:padding="@dimen/large_margins"
android:layout_gravity="center_vertical"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_small_cross"
android:padding="@dimen/large_margins"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
</LinearLayout>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSignUp"
android:background="@mipmap/signup"
android:layout_marginRight="@dimen/margin_default"
android:layout_gravity="center_horizontal"
/>
</LinearLayout>
</ScrollView>
再添加一个 LinearLayout
包含所有其他 LinearLayouts
勾选Doc
A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects.
ScrollView 一切正常。
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"<br>
这段代码是你的祸害。因为你给第一个 child 留了余地,它没有显示完整的 content.Change 它给
android:paddingBottom="32dp"
android:paddingTop="32dp"