我一直有麻烦,我的布局没有自动滚动时,键入和选择输入类型的联系人号码,我有两个xml
文件与此布局一个是我的输入字段的主体,另一个是页脚,其中有上一个和下一个按钮,我试图使用android:layout_marginTop="100dp"
到我的页脚XML,但没有工作,有人能帮助我吗
正文.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/primary"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:layout_margin="15dp"
android:textStyle="bold"
android:text="I. Demographics"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15dp" />
</LinearLayout>
<ScrollView
android:background="@color/white"
android:layout_width="wrap_content"
android:layout_height="660dp"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="80dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_hh_id"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_marginRight="10dp"
app:counterEnabled="true"
app:counterMaxLength="30"
app:endIconMode="clear_text"
app:errorEnabled="true"
app:helperText="Search Household ID!"
app:helperTextTextColor="@color/validation"
app:startIconDrawable="@drawable/ic_hh">
<EditText
android:id="@+id/edt_hh_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Household no."
android:inputType="text"
android:maxLength="30"
android:text="160310001-"
/>
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
<Button
android:id="@+id/btnSearchHh"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:padding="10dp"
android:text="Search"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_set"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_search"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:helperText="Required"
app:helperTextTextColor="@color/validation"
app:startIconDrawable="@drawable/ic_assigned">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@+id/aat_set"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:hint="Set"
android:inputType="none" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_last_name"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_set"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
app:endIconMode="clear_text"
app:helperText="Required"
app:helperTextTextColor="@color/validation"
app:startIconDrawable="@drawable/ic_person">
<EditText
android:id="@+id/edt_last_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Last Name:"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_first_name"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_last_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
app:endIconMode="clear_text"
app:helperText="Required"
app:helperTextTextColor="@color/validation"
app:startIconDrawable="@drawable/ic_lastname">
<EditText
android:id="@+id/edt_first_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First name"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_middle_name"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_first_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
app:endIconMode="clear_text"
app:startIconDrawable="@drawable/ic_middle">
<EditText
android:id="@+id/edt_middle_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Middle name"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_relationship_to_grantee"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_middle_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:helperText="Required"
app:helperTextTextColor="@color/validation"
app:startIconDrawable="@drawable/ic_baseline_escalator_warning_24">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@+id/aat_relationship_to_grantee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:hint="Relationship to Grantee" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_contact_no"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_relationship_to_grantee"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:counterEnabled="true"
app:counterMaxLength="10"
app:endIconMode="clear_text"
app:helperText="Required"
app:helperTextTextColor="@color/validation">
<EditText
android:id="@+id/edt_contact_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/icon_contacts"
android:drawableLeft="@drawable/icon_contacts"
android:drawablePadding="6dp"
android:hint="Contact No."
android:inputType="number"
android:maxLength="10" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_contact_no_of"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_contact_no"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:helperText="Required"
app:helperTextTextColor="@color/validation"
app:startIconDrawable="@drawable/ic_baseline_person_24">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@+id/aat_contact_no_of"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:hint="Contact No. of?" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
页脚.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Scanner.ScanCashCard">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints" />
<LinearLayout
android:layout_marginTop="100dp"
android:id="@+id/layoutDots"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:orientation="horizontal"
android:background="@color/primary"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:id="@+id/tvPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_marginBottom="25dp"
android:text="PREV"
android:textColor="@android:color/white"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tvNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_marginBottom="25dp"
android:text="NEXT"
android:textColor="@android:color/white"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<LinearLayout
android:id="@+id/linear2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:padding="5dp"
app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:id ="@+id/imageIv"
android:height ="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
已更新在我的清单中我添加了windowSoftInputMode
,但它似乎不起作用
<activity
android:name=".Scanner.ScanCashCard"
android:windowSoftInputMode="adjustResize|adjustPan"
android:parentActivityName=".MainActivity"/>
1条答案
按热度按时间vsnjm48y1#
1.使用
<FrameLayout>
作为根标记,将页脚布局和正文布局堆叠在彼此的顶部1.使用
<include>
标记将footer.xml布局添加到body.xml中1.将
android:layout_height="match_parent"
设置为<ScrollView>
1.不需要设置此
android:windowSoftInputMode="adjustResize|adjustPan"
**注:**这将使只有
<ScrollView>
内的东西向上滚动,其余布局将在屏幕上不变时,软板出现,我认为这是有意义的。忽略图标和颜色的gif附件。代码如下: