【问题标题】:android virtual keyboard changes the position of button and place it over edittext on focusandroid虚拟键盘更改按钮的位置并将其放在edittext上焦点
【发布时间】:2014-05-05 11:36:56
【问题描述】:

我创建了一个应用程序,其中有一个可从用户那里获取输入的编辑文本,在它下方有一个按钮。当用户单击或关注编辑文本以输入某些内容时,键盘会更改按钮位置并与编辑文本重叠。我已尝试
this 答案中提供的解决方案。但这对我没有帮助

我用过这个

android:windowSoftInputMode="stateVisible|adjustNothing

请人帮忙....

编辑: 这是我的布局 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>

【问题讨论】:

  • 请在此处显示您的 xml 布局...
  • @umair.ali 我已经展示了我的布局 xml...

标签: android android-layout android-softkeyboard


【解决方案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"

来自按钮属性。一切都像一个魅力......

【讨论】:

    【解决方案2】:

    添加android:windowSoftInputMode="adjustPan"

    在您的ActivityAndroid Manifest XML 文件中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-03
      • 1970-01-01
      • 2013-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多