我该如何定位布图设计权利的android屏幕上的键盘上方? [英] How can I position a layout right above the android on-screen keyboard?
本文介绍了我该如何定位布图设计权利的android屏幕上的键盘上方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请参阅所附照片。微博是否良好。他们有一个布局,我会打电话给一个工具栏,缺少一个更好的词,右边的屏幕键盘上方。我怎样才能做到这一点与我的code?
更新: 这是我的布局:
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:后台=#FFFFFF>
< RelativeLayout的机器人:ID =@ + ID / actionbarRelativeLayout机器人:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT机器人:背景=@可绘制/ actionbar_gradient>
< ImageButton的机器人:ID =@ + ID / ImageButton的机器人:layout_width =WRAP_CONTENT机器人:背景=@可绘制/ StockTwits的机器人:layout_height =WRAP_CONTENT>< / ImageButton的>
< TextView的Android的:layout_width =WRAP_CONTENT机器人:ID =@ + ID / charCountTextView机器人:文本=140机器人:layout_alignParentRight =真正的机器人:layout_height =WRAP_CONTENT机器人:文字颜色=#FFFFFF机器人:TEXTSTYLE =黑体的Android版本:TEXTSIZE =18sp安卓重力=center_vertical机器人:layout_centerVertical =真正的>< / TextView的>
< / RelativeLayout的>
< EditText上的android:layout_width =match_parent机器人:ID =@ + ID / composeEditText机器人:可聚焦=真正的机器人:提示=共享一个想法,用之社会的Android版本:重力=左|顶机器人:layout_height =FILL_PARENT机器人:layout_weight =1>< /的EditText>
< LinearLayout中的android:layout_width =match_parent机器人:ID =@ + ID /边框机器人:后台=#c4c4c4机器人:baselineAligned =假的Android版本:layout_height =1DP>< / LinearLayout中>
< LinearLayout中的android:layout_height =WRAP_CONTENT机器人:ID =@ + ID / toolbarLinearLayout机器人:方向=横向机器人:填充=5dip机器人:layout_width =FILL_PARENT机器人:背景=@可绘制/ gray_toolbar_gradient>
<按钮机器人:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / shortenButton机器人:背景=@可绘制/ shortenbutton机器人:layout_weight =0>< /按钮>
< LinearLayout中的android:layout_height =match_parent机器人:layout_width =WRAP_CONTENT机器人:ID =@ + ID / linearLayout1机器人:layout_weight =1>< / LinearLayout中>
<复选框机器人:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / twitterCheckBox机器人:文字颜色=#000000机器人:layout_weight =0安卓背景=@可绘制/ twittergraybutton>< /复选框>
<按钮机器人:layout_height =WRAP_CONTENT机器人:layout_weight =0机器人:ID =@ + ID / sendButton机器人:layout_width =WRAP_CONTENT机器人:背景=@可绘制/ sharebutton>< /按钮>
< / LinearLayout中>
< / LinearLayout中>
这里是我的清单,我指定softInputMode:
<活动机器人:名称=ShareActivity
机器人:主题=@安卓风格/ Theme.NoTitleBar
机器人:windowSoftInputMode =adjustResize>
< /活性GT;
解决方案
请确保您的软输入模式设置为adjustResize ,然后将你的工具栏的布局,在你的活动的底部。
例如:
<的LinearLayout机器人:方向=垂直
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<的FrameLayout机器人:ID =@ + ID / my_content
机器人:layout_width =match_parent
机器人:layout_height =0dip
机器人:layout_weight =1>
<! - 你的内容在这里 - >
< /的FrameLayout>
<的LinearLayout机器人:ID =@ + ID / my_toolbar
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT>
<! - 你的工具栏项目在这里 - >
< / LinearLayout中>
< / LinearLayout中>
See the attached photo. Twitter does it well. They have a layout, which I will call a toolbar for lack of a better term, right above the onscreen keyboard. How can I do this with my code?
UPDATE: Here is my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<RelativeLayout android:id="@+id/actionbarRelativeLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/actionbar_gradient">
<ImageButton android:id="@+id/imageButton" android:layout_width="wrap_content" android:background="@drawable/stocktwits" android:layout_height="wrap_content"></ImageButton>
<TextView android:layout_width="wrap_content" android:id="@+id/charCountTextView" android:text="140" android:layout_alignParentRight="true" android:layout_height="wrap_content" android:textColor="#ffffff" android:textStyle="bold" android:textSize="18sp" android:gravity="center_vertical" android:layout_centerVertical="true"></TextView>
</RelativeLayout>
<EditText android:layout_width="match_parent" android:id="@+id/composeEditText" android:focusable="true" android:hint="Share an idea with the community" android:gravity="left|top" android:layout_height="fill_parent" android:layout_weight="1"></EditText>
<LinearLayout android:layout_width="match_parent" android:id="@+id/border" android:background="#c4c4c4" android:baselineAligned="false" android:layout_height="1dp"></LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:id="@+id/toolbarLinearLayout" android:orientation="horizontal" android:padding="5dip" android:layout_width="fill_parent" android:background="@drawable/gray_toolbar_gradient">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/shortenButton" android:background="@drawable/shortenbutton" android:layout_weight="0"></Button>
<LinearLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:id="@+id/linearLayout1" android:layout_weight="1"></LinearLayout>
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/twitterCheckBox" android:textColor="#000000" android:layout_weight="0" android:background="@drawable/twittergraybutton"></CheckBox>
<Button android:layout_height="wrap_content" android:layout_weight="0" android:id="@+id/sendButton" android:layout_width="wrap_content" android:background="@drawable/sharebutton"></Button>
</LinearLayout>
</LinearLayout>
And here is my Manifest where I specify the softInputMode:
<activity android:name="ShareActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustResize">
</activity>
解决方案
Make sure your soft input mode is set to adjustResize, then place the layout with your toolbar at the bottom of your activity.
Example:
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout android:id="@+id/my_content"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<!-- Your content here -->
</FrameLayout>
<LinearLayout android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Your toolbar items here -->
</LinearLayout>
</LinearLayout>
这篇关于我该如何定位布图设计权利的android屏幕上的键盘上方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文