【发布时间】:2015-07-25 00:05:59
【问题描述】:
我想要的是,当用户单击其中一个编辑文本以调整屏幕大小并向上滚动时,它会专注于该编辑文本。
清单已设置为调整大小:
<activity
android:name=".ui.login.LoginActivity"
android:label="@string/app_name"
android:theme="@style/AppThemes"
android:windowSoftInputMode="stateHidden|adjustResize"/>
登录屏幕的 XML 布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="matrix"
android:src="@drawable/main_background" />
<ScrollView
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">
<!--<LinearLayout-->
<!--android:id="@+id/login_header"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:paddingTop="30dp"-->
<!--android:paddingBottom="30dp"-->
<!--android:gravity="center_horizontal"-->
<!--android:orientation="vertical">-->
<!--<ImageView-->
<!--android:id="@+id/login_fragment_logo"-->
<!--android:layout_width="120dp"-->
<!--android:layout_height="120dp"-->
<!--android:src="@drawable/logo_with_dropshadow" />-->
<!--<TextView-->
<!--android:id="@+id/login_fragment_app_title"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_margin="5dp"-->
<!--android:text="@string/digital_door_viewer"-->
<!--android:textAllCaps="true"-->
<!--android:textSize="18sp" />-->
<!--</LinearLayout>-->
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/login_fragment_email_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:background="@color/white"
android:hint="@string/email"
android:inputType="textEmailAddress"
android:padding="8dp"
android:singleLine="true"
android:textSize="20sp"/>
<EditText
android:id="@+id/login_fragment_password_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:hint="@string/password"
android:inputType="textPassword"
android:padding="8dp"
android:singleLine="true"
android:textSize="20sp" />
<Button
android:id="@+id/login_fragment_register_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="7dp"
android:layout_marginTop="10dp"
android:background="@android:color/transparent"
android:minHeight="0dp"
android:text="@string/register"
android:textAllCaps="false"
android:textSize="16sp" />
<Button
android:id="@+id/login_fragment_forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="15dp"
android:layout_marginTop="5dp"
android:background="@android:color/transparent"
android:minHeight="0dp"
android:text="@string/forgot_your_password"
android:textAllCaps="false"
android:textSize="16sp" />
<Button
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/yellow_selector"
android:minHeight="0dp"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:text="@string/login"
android:textAllCaps="true"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
出了什么问题,当我取消注释屏幕的标题时,它不会向上滚动,但注释掉它会按预期工作......我错过了什么?
【问题讨论】:
-
我看到了你的网站。你更圆了。哈在所有领域。
-
:) 尽量做到至少
-
坚持下去....我怎样才能下载你的歌曲???
-
给我发一个github issue,我会折腾下载github.com/isuPatches/RockThePatch
-
您可以发布您的编辑文本的代码吗?
标签: android android-layout scrollview