Android軟鍵盤彈出將底部欄頂上去並不會擠壓介面

來源:互聯網
上載者:User

標籤:

     介面需要,找到了一種不需要去設定android:windowSoftInputMode屬性的解決keyboard和layout不適問題

     有關設定android:windowSoftInputMode的資料,可自行百度。

     我的方法就是,將xml檔案的根布局設定成ScrollView,將之前的布局嵌套在裡面就行了,不需要去設定以上的任何屬性

     在中間沒有控制項顯示的地方,使用view設定weight去佔位置

    下面給出我的xml布局

    

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:fillViewport="true"    tools:context="com.example.richedit.TestInputMethodActivity" >    <LinearLayout         android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:orientation="vertical">        <LinearLayout             android:layout_width="fill_parent"            android:layout_height="40dp"            android:background="#332423">                    </LinearLayout>        <View android:layout_width="match_parent"            android:layout_height="0dp"            android:layout_weight="1"/>        <EditText             android:layout_width="match_parent"            android:layout_height="wrap_content"/>        <EditText             android:layout_width="match_parent"            android:layout_height="wrap_content"/>        <View             android:layout_width="match_parent"            android:layout_height="0dp"            android:layout_weight="1"/>        <RelativeLayout             android:layout_width="fill_parent"              android:layout_height="54dip"              android:background="@android:drawable/bottom_bar">            <Button                  android:id="@+id/manual_setup"                  android:text="zuozuo"                  android:layout_height="wrap_content"                  android:layout_width="wrap_content"                  android:minWidth="100dp"                  android:layout_alignParentLeft="true"                  android:layout_centerVertical="true" />              <Button                  android:id="@+id/next"                  android:text="youyou"                  android:layout_height="wrap_content"                  android:layout_width="wrap_content"                  android:minWidth="100dp"                  android:layout_alignParentRight="true"                  android:layout_centerVertical="true" />          </RelativeLayout>    </LinearLayout></ScrollView>

 

   這裡給出keyb彈出時和沒彈出時的,很好的將底部欄頂了上去

  

             

 

Android軟鍵盤彈出將底部欄頂上去並不會擠壓介面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.