我创建了一个应用程序,其中有一个edittext来从用户那里获取输入,在它下面有一个按钮。当用户单击或关注edittext以输入某些内容时,键盘会更改按钮位置,并且它与edittext重叠。我试过了提供的解决方案 this 回答。但它并没有帮助我
我用过这个
android:windowSoftInputMode="stateVisible|adjustNothing
请p某人......
修改 这是我的布局xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#ffffff"
tools:context=".MyAds"
android:id="@+id/TestAd"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
<EditText
android:id="@+id/edtLoanAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtLoanAmount"
android:layout_alignParentRight="true"
android:layout_below="@+id/txtLoanAmount"
android:ems="10"
android:background="@drawable/rounded_edittext_states"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/edtRateOfInterest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtRateOfInerest"
android:layout_alignParentRight="true"
android:layout_below="@+id/txtRateOfInerest"
android:ems="10"
android:background="@drawable/rounded_edittext_states"
android:inputType="numberDecimal" />
<TextView
android:id="@+id/txtRateOfInerest"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/edtLoanAmount"
android:layout_below="@+id/edtLoanAmount"
android:layout_marginTop="14dp"
android:text="Rate of Inerest"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtLoanAmount"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="16dp"
android:text="Enter Loan Amount"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtLoanTenure"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/edtRateOfInterest"
android:layout_marginTop="16dp"
android:text="Loan Tenure (In Months)"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/edtLoanTenure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/txtLoanTenure"
android:ems="10"
android:background="@drawable/rounded_edittext_states"
android:inputType="number" />
<TextView
android:id="@+id/txtEMI"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btnCalculateEmi"
android:layout_marginTop="20dp"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/btnLoanAmorSchedule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtEMI"
android:layout_marginTop="16dp"
android:background="@drawable/rounded_button_states"
android:text="Loan Amortization Schedule" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="125dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/initqube" />
<Button
android:id="@+id/btnCalculateEmi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingTop="3dp"
android:layout_marginTop="5dp"
android:layout_below="@id/edtLoanTenure"
android:background="@drawable/rounded_button_states"
android:text="Calculate EMI" />
<com.google.android.gms.ads.AdView
android:id="@+id/MyAdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView1"
android:layout_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxx" >
</com.google.android.gms.ads.AdView>
</RelativeLayout>
</ScrollView>
答案 0 :(得分:1)
我的问题已经解决了......
<Button
android:id="@+id/btnCalculateEmi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingTop="3dp"
android:layout_marginTop="5dp"
android:layout_below="@id/edtLoanTenure"
android:background="@drawable/rounded_button_states"
android:text="Calculate EMI" />
删除
后android:layout_centerVertical="true"
来自按钮属性的。一切都像魅力......
答案 1 :(得分:-1)
添加android:windowSoftInputMode="adjustPan"
在Android Manifest XML
的{{1}}文件中。