当edittext设置为V时,带有选项卡的操作栏会上升(true)

时间:2018-02-15 11:35:33

标签: android android-layout android-fragments android-actionbar

" EditText"片段中的视图最初设置为Visiblity.GONE。但是,当用户从d下拉列表中选择一个项目时,我会动态显示它。它使带有标签的操作栏上升并且不会返回。如图所示:

不可见时(GONE)。

enter image description here

可见时。

enter image description here

  

清单文件

<activity
    android:name=".LoanAppEducationActivity"
    android:label="@string/title_activity_loan_app_education"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.NoActionBar"
    android:windowSoftInputMode="adjustPan">
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="com.mitron.mystro.EducationalLoansActivity" />
</activity>
  

activity_loan_app_education.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.mitron.mystro.LoanAppEducationActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:isScrollContainer="false"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_weight="1"
            android:isScrollContainer="false"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:title="@string/app_name"
            app:subtitle="@string/app_subtitle">

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:isScrollContainer="false"
            app:tabBackground="@android:color/white"
            android:layout_width="match_parent"
            android:layout_height="4dp">

            <android.support.design.widget.TabItem
                android:id="@+id/personal_details"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <android.support.design.widget.TabItem
                android:id="@+id/educational_details"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <android.support.design.widget.TabItem
                android:id="@+id/loan_details"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <android.support.design.widget.TabItem
                android:id="@+id/document_page"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </android.support.design.widget.TabLayout>
    </android.support.design.widget.AppBarLayout>

    <com.mitron.mystro.helper.view.MyViewPager
        android:id="@+id/container"
        android:isScrollContainer="false"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>
  

这是问题似乎是

的片段文件

导致问题的EditText是在此布局中包含的布局中。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/education_occupation_scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:scrollbars="none"
    android:focusable="false"
    android:paddingBottom="16dp"
    android:isScrollContainer="false"
    tools:context="com.mitron.mystro.educational_loans.EduEducationOccupationFragment">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="16dp"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginTop="8dp"
                android:text="@string/educational_occupational_details"
                android:textSize="@dimen/form_edit_text_size"
                android:textStyle="bold" />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="end"
                android:text="@string/mandatory"/>
        </LinearLayout>

        <include layout="@layout/educational_detail_form" />

        <View
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="?attr/actionBarSize" />

    </LinearLayout>

</ScrollView>
  

包含的布局education_detail_form.xml

<LinearLayout 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="wrap_content"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="0dp"
        android:layout_marginTop="4dp"
        android:text="@string/select_your_highest_qualification"
        android:textSize="@dimen/form_edit_text_size" />

    <com.jaredrummler.materialspinner.MaterialSpinner
        android:id="@+id/educational_detail_highest"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="4dp"
        android:layout_marginTop="0dp"
        android:hint="@string/select_your_highest_qualification"
        android:textSize="@dimen/form_edit_text_size"
        app:ms_hint="@string/not_selected" />

    <android.support.design.widget.TextInputLayout
        android:id="@+id/other_qualification_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="beforeDescendants"
        android:focusableInTouchMode="true" >

        <EditText
            android:id="@+id/other_qualification"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="4dp"
            android:layout_marginTop="4dp"
            android:hint="@string/enter_your_highest_qualification"
            android:inputType="textPersonName|textAutoComplete"
            android:textSize="@dimen/form_edit_text_size" />

    </android.support.design.widget.TextInputLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="0dp"
        android:layout_marginTop="4dp"
        android:text="@string/select_your_current_occupation"
        android:textSize="@dimen/form_edit_text_size" />

    <com.jaredrummler.materialspinner.MaterialSpinner
        android:id="@+id/educational_detail_current_occupation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="4dp"
        android:layout_marginTop="4dp"
        android:hint="@string/select_your_current_occupation"
        android:textSize="@dimen/form_edit_text_size"
        app:ms_hint="@string/not_selected" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/academic_profile_recycler"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="4dp"
        android:layout_marginTop="4dp" />

    <LinearLayout
        android:id="@+id/salaried_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:id="@+id/form_name_of_company"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="4dp"
                android:layout_marginTop="4dp"
                android:hint="@string/name_of_the_company"
                android:inputType="textPersonName|textAutoComplete"
                android:textSize="@dimen/form_edit_text_size" />

        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.mitron.mystro.helper.view.DateTextView
                android:id="@+id/form_working_since"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/working_since"
                android:textSize="@dimen/form_edit_text_size"
                app:dateCase="@integer/case_working_since" />

        </android.support.design.widget.TextInputLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="0dp"
            android:layout_marginTop="4dp"
            android:text="@string/net_monthly_income"
            android:textSize="@dimen/form_edit_text_size" />

        <EditText
            android:id="@+id/form_net_monthly_income"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="4dp"
            android:layout_marginTop="0dp"
            android:hint="@string/fig_in_rupee"
            android:inputType="number"
            android:maxEms="10"
            android:maxLines="1"
            android:textSize="@dimen/form_edit_text_size" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="0dp"
            android:layout_marginTop="4dp"
            android:text="@string/monthly_obligations"
            android:textSize="@dimen/form_edit_text_size" />

        <EditText
            android:id="@+id/form_net_monthly_obligations"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="4dp"
            android:layout_marginTop="0dp"
            android:hint="@string/fig_in_rupee"
            android:inputType="number"
            android:maxEms="10"
            android:maxLines="1"
            android:textSize="@dimen/form_edit_text_size" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="0dp"
            android:layout_marginTop="4dp"
            android:text="@string/office_address"
            android:textSize="@dimen/form_edit_text_size" />

        <include layout="@layout/address_lines" />
    </LinearLayout>
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

从工具栏中删除此行:

 app:layout_scrollFlags="scroll|enterAlways"

完整代码:

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_weight="1"
        android:isScrollContainer="false"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:title="@string/app_name"
        app:subtitle="@string/app_subtitle">

通过Java代码删除:

Toolbar toolbar = findViewById(R.id.toolbar);  // or however you need to do it for your code
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
params.setScrollFlags(0);  // clear all scroll flags