【问题标题】:How to make footer buttons fixed in native android application?如何在本机 android 应用程序中固定页脚按钮?
【发布时间】:2012-01-30 12:57:08
【问题描述】:

在我的项目中,我使用页脚中的按钮,当在文本框中输入任何文本时,qwerty 键盘打开,同时按钮更改了页脚位置并显示在键盘上方。这是我的代码

<LinearLayout
    android:layout_alignParentRight="true"
    android:background="#4D4D4D"
    android:id="@+id/linearLayout3"
    android:layout_width="fill_parent"
    android:layout_height="55dp"
    android:layout_marginTop="-55dp"  >
 <Button android:id="@+id/signout" android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:layout_weight="1"
        android:background="#4D4D4D"
        android:text="Add Spot"
        android:textSize="15px"
        android:padding="8px">
</Button>    
</LinearLayout>

【问题讨论】:

  • 你要修复底部的按钮吗?
  • @himanshu 是的,我想保持页脚按钮固定
  • 我已经发布了答案。

标签: android android-layout android-emulator android-ndk


【解决方案1】:

添加这一行

android:windowSoftInputMode="stateVisible|adjustResize|adjustPan"

在清单文件中。

【讨论】:

    【解决方案2】:

    在 manifest.xml 中将 Activity 的 windowSoftInputMode 设置为未更改状态。

    【讨论】:

    • 我在清单文件中添加了himanshu的代码,现在它可以工作了
    【解决方案3】:

    您只需要在清单文件的活动标签中添加一个参数

    <activity android:windowSoftInputMode="adjustPan"  
    

    当您打开键盘时,您的按钮仍处于底部。

    【讨论】:

      【解决方案4】:

      像这样?

      <LinearLayout
      android:layout_alignParentRight="true"
      android:background="#4D4D4D"
      android:id="@+id/linearLayout3"
      android:layout_width="fill_parent"
      android:layout_height="55dp"
      android:layout_marginTop="-55dp"  >
      
          <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_weight="1">
          </LinearLayout>
      
          <Button android:id="@+id/signout" android:layout_height="wrap_content"
          android:layout_width="wrap_content" android:layout_weight="1"
          android:background="#4D4D4D"
          android:text="Add Spot"
          android:textSize="15px"
          android:padding="8px">
          </Button>    
      
      </LinearLayout>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-01-05
        • 1970-01-01
        • 2011-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-09-28
        相关资源
        最近更新 更多