在我的android项目中,我有以下xml文件: -
<LinearLayout 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:gravity="center_vertical|center_horizontal"
android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" tools:context=".LoginActivity"
android:background="#ffBE80FF"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
<LinearLayout
android:id="@+id/ll1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="FOOBAR"
android:id="@+id/textView2"
android:textSize="30dp"
android:textColor="#ffffffff" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal">
<ProgressBar android:id="@+id/login_progress" style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" />
<ScrollView android:id="@+id/login_form" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- <LinearLayout android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"> -->
<AutoCompleteTextView android:id="@+id/email" android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/prompt_email"
android:inputType="textEmailAddress" android:maxLines="1"
android:singleLine="true"
android:layout_marginBottom="10dp"
android:textColorHint="#ffffffff"
android:textColor="#ffffffff" />
<EditText android:id="@+id/password" android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/prompt_password"
android:imeActionLabel="@string/action_sign_in"
android:imeOptions="actionUnspecified" android:inputType="textPassword"
android:maxLines="1" android:singleLine="true"
android:layout_marginBottom="10dp"
android:textColorHint="#ffffffff"
android:textColor="#ffffffff"
android:layout_weight="0.5"/>
<Button android:id="@+id/email_sign_in_button" style="?android:textAppearanceSmall"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:text="@string/action_sign_in"
android:textStyle="bold"
android:textColor="#ffffffff"
android:background="#ff7e51c2"
android:layout_weight="0.5"/>
<!-- </LinearLayout> -->
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/ll3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign up"
android:id="@+id/signUpTextView"
android:autoLink="web"
android:textColor="#ffffffff" />
</LinearLayout>
</LinearLayout>
它正确显示我需要的东西。看起来如下图: -
但是当我想填写表格时。登录按钮不可见。 它看起来如下图: -
我的代码中出错了什么?当我想填写编辑文本字段时,为什么它不可见?请各位建议我。
答案 0 :(得分:1)
这就是你所需要的:
<LinearLayout
android:id="@+id/ll1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="FOOBAR"
android:id="@+id/textView2"
android:textSize="30dp"
android:textColor="#ffffffff" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal">
<ProgressBar android:id="@+id/login_progress" style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" />
<ScrollView android:id="@+id/login_form" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- <LinearLayout android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"> -->
<AutoCompleteTextView android:id="@+id/email" android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/prompt_email"
android:inputType="textEmailAddress" android:maxLines="1"
android:singleLine="true"
android:layout_marginBottom="10dp"
android:textColorHint="#ffffffff"
android:textColor="#ffffffff" />
<EditText android:id="@+id/password" android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/prompt_password"
android:imeActionLabel="@string/action_sign_in"
android:imeOptions="actionUnspecified" android:inputType="textPassword"
android:maxLines="1" android:singleLine="true"
android:layout_marginBottom="10dp"
android:textColorHint="#ffffffff"
android:textColor="#ffffffff"
android:layout_weight="0.5"/>
<Button android:id="@+id/email_sign_in_button" style="?android:textAppearanceSmall"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:text="@string/action_sign_in"
android:textStyle="bold"
android:textColor="#ffffffff"
android:background="#ff7e51c2"
android:layout_weight="0.5"/>
<!-- </LinearLayout> -->
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/ll3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign up"
android:id="@+id/signUpTextView"
android:autoLink="web"
android:textColor="#ffffffff" />
</LinearLayout>