当前位置:编程学习 > wap >>

如何实现 软键盘弹出button与edittext一起上移,且背景不上移或者被压缩?

如题,最近想实现一个登录界面,类似于“街旁”的登录页(如下图),
要求 当选中区域B中的任意edittext时,B区域一起上移,但A区域保持不变(即 不被软键盘挤压,也不会上移)……
调了半天布局文件,还是没有获得满意的效果,
现在已经可以实现B区域一起上移,但是弹出软键盘背景图案(A区域)还是会上移或者被挤压……很郁闷~~

有没有哪位大神知道这种布局效果到底是如何实现的呀~~~不胜感激呀orz
--------------------编程问答-------------------- 图片看不到,但是我大概明白了你的意思,AndroidManifest.xml里面你需要完成这个效果的对应Activity节点下有一个属性,好像是android:inputSoftMode,应该是跟这个差不多的一个属性,找找看。
(刚来新公司,电脑还没弄好,环境没装上,所以没法看具体属性名) --------------------编程问答-------------------- 图片看不到,补充个图片地址吧,有劳各位高手啦

/upload/20131225/2c5947d4ad6eddc4581ad04839dbb6fd53663335.gif --------------------编程问答-------------------- 你说的是android:windowSoftInputMode这个属性吧,里面的9种模式都试了一遍貌似还是不行,
我觉得是把edittext和button都放在一个自定义的AlertDialog里面,背景图案直接放在AlertDialog下面Activity里面,会不会是这样实现的?
引用 1 楼 lingang1359 的回复:
图片看不到,但是我大概明白了你的意思,AndroidManifest.xml里面你需要完成这个效果的对应Activity节点下有一个属性,好像是android:inputSoftMode,应该是跟这个差不多的一个属性,找找看。
(刚来新公司,电脑还没弄好,环境没装上,所以没法看具体属性名)
--------------------编程问答-------------------- 原来很简单,只是自己想复杂了,终于出来了

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:orientation="vertical" 
android:id="@+id/relativeLayout3"
android:background="@drawable/bg">
<ScrollView 
android:layout_height="fill_parent" 
android:layout_width="wrap_content" >
<LinearLayout 
android:id="@+id/linearLayout1" 
android:layout_width="match_parent" 
android:layout_height="match_parent"
android:background="@drawable/bg"></LinearLayout>
</ScrollView>
<RelativeLayout 
android:gravity="center" 
android:id="@+id/relativeLayout3"
android:layout_height="wrap_content"
android:layout_width="fill_parent" 
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="50dip"
android:background="@drawable/bg_btn">
<LinearLayout 
    android:layout_height="wrap_content" 
    android:id="@+id/linearLayout2" 
   android:gravity="center_horizontal" 
    android:layout_width="fill_parent" 
    android:layout_margin="10dip">
    <TextView 
        android:id="@+id/textView2"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"></TextView>
        <EditText 
        android:id="@+id/editAccount" 
        android:layout_width="250dip" 
        android:layout_height="wrap_content"
        android:singleLine="true"></EditText>  
    </LinearLayout>
    <LinearLayout 
    android:layout_height="wrap_content" 
    android:id="@+id/linearLayout3"
    android:gravity="center_horizontal" 
    android:layout_width="fill_parent"
    android:layout_below="@+id/linearLayout2">
    <TextView 
        android:id="@+id/textView2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"></TextView>
        <EditText 
        android:password="true"
        android:id="@+id/editPassword" 
        android:layout_width="250dip" 
        android:layout_height="wrap_content"
        android:singleLine="true"></EditText>
    </LinearLayout>
<LinearLayout 
        android:layout_height="wrap_content" 
        android:id="@+id/linearLayout7"
        android:gravity="center_horizontal" 
        android:layout_width="fill_parent"
        android:layout_below="@+id/linearLayout3">
            <Button 
            android:id="@+id/buttonLogin" 
            android:layout_width="80dip" 
            android:layout_height="wrap_content"></Button>
            <Button 
            android:id="@+id/buttonRegeister" 
            android:layout_width="80dip" 
            android:layout_height="wrap_content"></Button>
        </LinearLayout>
</RelativeLayout>
</RelativeLayout> --------------------编程问答-------------------- 我用的版本是4.03,之前不可以的,因为我的mainifestt.xml文件中加上了 android:theme="@android:style/Theme.NoTitleBar.Fullscreen",这样就冲突了,去掉就可以了
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,