我的活动上有一个登录表单。我需要这个逻辑:
http://www.clipular.com/c/6455748191322112.png?k=Xc28Y-FsMShuNpEXbWD5rpe6faY http://www.clipular.com/c/5414772807041024.png?k=k3TB9AiHEtdV8oh6G17Ag-MS2nI
我怎么能这样做?我已尝试将android:windowSoftInputMode="adjustPan"
设置为清单中的Activity
,但这不起作用。
我的布局:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/truck">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logo"
android:layout_width="@dimen/login_logo_width"
android:layout_height="@dimen/login_logo_height"
android:layout_marginTop="@dimen/login_logo_margin_top"
android:layout_marginStart="@dimen/login_logo_margin_left"
android:src="@drawable/logo_transfort_white"
android:contentDescription="@string/logo_title"/>
<TextView
android:id="@+id/skip"
style="@style/GrayText"
android:layout_width="wrap_content"
android:layout_height="@dimen/default_text_height"
android:layout_alignEnd="@id/logo"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/skip_button_margin_right"
android:layout_marginTop="@dimen/skip_button_margin_top"
android:gravity="center"
android:text="@string/skip" />
<LinearLayout
android:id="@+id/inputs"
android:background="@drawable/login_buttons_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/inputs_block_margin_top"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:layout_marginEnd="@dimen/inputs_block_margin_left_right"
android:layout_below="@id/logo"
android:orientation="vertical"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
<EditText
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="@dimen/default_text_height"
android:layout_marginTop="@dimen/inputs_block_margin_left_right"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:background="@color/text_color_white_transparent"
android:ems="16"
android:hint="@string/login"
style="@style/LoginInputs"/>
<View
android:id="@+id/inputs_line"
android:layout_width="wrap_content"
android:layout_height="@dimen/login_line_height"
android:layout_marginTop="@dimen/login_line_margin_top"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:layout_marginEnd="@dimen/inputs_block_margin_left_right"
android:background="@color/line_color_white_capacity" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="@dimen/default_text_height"
android:layout_marginTop="@dimen/login_line_margin_top"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:layout_marginBottom="@dimen/inputs_block_margin_left_right"
android:background="@color/text_color_white_transparent"
android:ems="16"
android:hint="@string/password"
android:inputType="textPassword"
style="@style/LoginInputs" />
</LinearLayout>
<TextView
android:id="@+id/forgot_password"
android:layout_width="wrap_content"
android:layout_height="@dimen/default_text_height"
android:layout_below="@id/inputs"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/forgot_password_margin_top"
android:layout_marginEnd="@dimen/inputs_block_margin_left_right"
android:text="@string/forgot_password"
android:gravity="center"
style="@style/WhiteText" />
<Button
android:id="@+id/enter"
android:background="@drawable/sigin_button_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/forgot_password"
android:layout_centerHorizontal="true"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:layout_marginEnd="@dimen/inputs_block_margin_left_right"
android:layout_marginTop="@dimen/signin_button_margin_top"
android:textColor="@android:color/white"
android:text="@string/enter_text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/enter"
android:orientation="horizontal">
<TextView
android:id="@+id/no_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/no_account_margin_left"
android:layout_marginTop="@dimen/no_account_margin_top"
android:text="@string/no_account"
style="@style/GrayText"/>
<TextView
android:id="@+id/check_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/check_in_margin_left"
android:layout_marginTop="@dimen/no_account_margin_top"
android:text="@string/check_in"
style="@style/WhiteText" />
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:1)
将ScrollView
设为父版布局
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
// add here all your controls
</LinearLayout>
</ScrollView>
而不是
您活动中的 android:windowSoftInputMode="adjustPan"
<activity
android:name=".activity.TempActivity"
android:windowSoftInputMode="adjustPan"
android:theme="@style/AppTheme.NoActionBar"/>
答案 1 :(得分:0)
我是这样做的:
<FrameLayout 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:fitsSystemWindows="true"
android:background="@android:color/black">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:background="@drawable/truck"
android:contentDescription="@string/truck" />
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/auth_gradient_height"
android:layout_gravity="bottom"
android:background="@drawable/background_gradient"
android:contentDescription="@string/gradient" />
</FrameLayout>
<View
android:id="@+id/overlay_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</View>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logo"
android:layout_width="@dimen/login_logo_width"
android:layout_height="@dimen/login_logo_height"
android:layout_marginTop="@dimen/login_logo_margin_top"
android:layout_marginStart="@dimen/login_logo_margin_left"
android:src="@drawable/logo_transfort_white"
android:contentDescription="@string/logo_title"/>
<TextView
android:id="@+id/skip"
style="@style/GrayText"
android:layout_width="wrap_content"
android:layout_height="@dimen/default_text_height"
android:layout_alignEnd="@id/logo"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/skip_button_margin_right"
android:layout_marginTop="@dimen/skip_button_margin_top"
android:gravity="center"
android:text="@string/skip" />
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/inputs"
android:background="@drawable/login_buttons_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/inputs_block_margin_top"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:layout_marginEnd="@dimen/inputs_block_margin_left_right"
android:orientation="vertical"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
<EditText
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="@dimen/default_text_height"
android:layout_marginTop="@dimen/inputs_block_margin_left_right"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:background="@color/text_color_white_transparent"
android:ems="16"
android:hint="@string/login"
style="@style/LoginInputs"/>
<View
android:id="@+id/inputs_line"
android:layout_width="wrap_content"
android:layout_height="@dimen/login_line_height"
android:layout_marginTop="@dimen/login_line_margin_top"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:layout_marginEnd="@dimen/inputs_block_margin_left_right"
android:background="@color/line_color_white_capacity" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="@dimen/default_text_height"
android:layout_marginTop="@dimen/login_line_margin_top"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:layout_marginBottom="@dimen/inputs_block_margin_left_right"
android:background="@color/text_color_white_transparent"
android:ems="16"
android:hint="@string/password"
android:inputType="textPassword"
style="@style/LoginInputs" />
</LinearLayout>
<TextView
android:id="@+id/error_message"
android:layout_width="wrap_content"
android:layout_height="@dimen/default_text_height"
android:layout_below="@id/inputs"
android:layout_marginTop="@dimen/forgot_password_margin_top"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
tools:text="@string/auth_error"
android:gravity="center"
style="@style/RedText" />
<TextView
android:id="@+id/forgot_password"
android:layout_width="wrap_content"
android:layout_height="@dimen/default_text_height"
android:layout_below="@id/inputs"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/forgot_password_margin_top"
android:layout_marginEnd="@dimen/inputs_block_margin_left_right"
android:text="@string/forgot_password"
android:gravity="center"
style="@style/WhiteText" />
<Button
android:id="@+id/enter"
android:background="@drawable/sigin_button_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/forgot_password"
android:layout_centerHorizontal="true"
android:layout_marginStart="@dimen/inputs_block_margin_left_right"
android:layout_marginEnd="@dimen/inputs_block_margin_left_right"
android:layout_marginTop="@dimen/signin_button_margin_top"
android:textColor="@android:color/white"
android:text="@string/enter_text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/enter"
android:orientation="horizontal">
<TextView
android:id="@+id/no_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/no_account_margin_left"
android:layout_marginTop="@dimen/no_account_margin_top"
android:text="@string/no_account"
style="@style/GrayText"/>
<TextView
android:id="@+id/check_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/check_in_margin_left"
android:layout_marginTop="@dimen/no_account_margin_top"
android:text="@string/check_in"
style="@style/WhiteText" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
但在这种情况下,我需要在键盘显示/隐藏时从代码滚动到按钮