zoukankan      html  css  js  c++  java
  • Android软键盘弹出将底部栏顶上去并不会挤压界面

         界面需要,找到了一种不需要去设置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弹出时和没弹出时的效果图,很好的将底部栏顶了上去

      

                 

  • 相关阅读:
    第四章 方法(4.2 方法的嵌套调用)
    C#利用for循环打印图形练习题
    第三章 C#程序结构 (3.3 循环结构)
    第六章 数组和索引器 (6.6 索引器)
    第五章 类与对象 5.2 猫类(案例二)
    第五章 类与对象 5.1 时间类(案例一)
    第三章 C#程序结构[3.2 选择结构的应用(Windows窗体应用程序)(四)]
    第三章 C#程序结构(3.1 顺序与选择结构)
    第二章 C#语法基础 (2.2 C#语言的运算符和表达式)
    第二章 C#语法基础(2.1C#语言的数据类型二)
  • 原文地址:https://www.cnblogs.com/robben/p/4832618.html
Copyright © 2011-2022 走看看