0

In Android, I have a RelativeLayout named A. It has a view named B in the top of A. It has a view named C in the bottom of A.

Code I have so far:

RelativeLayout A = new RelativeLayout(context);
View B = new View(context);
LayoutParams paramsB = new LayoutParams(LayoutParams.FILL_PARENT, 40);

paramsB.addRule(RelativeLayout.ALIGN_PARENT_TOP);
View C = new View(context);

LayoutParams paramsC = new LayoutParams(LayoutParams.FILL_PARENT, 40);
paramsC.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

A.addView(B,paramsB);
A.addView(C,paramsC);

How do I adjust the RelativeLayout size when the keyboard shows?

4

2 回答 2

0

我认为您可以将“A”相对布局的布局参数设置为 WRAP_CONTENT,这样当键盘从底部传来时,它将使用相对布局调整高度。我怀疑您添加到“B”和“C”相对布局的规则,因为您已将 Align_parent_bottom 和 Align_parent_top 添加为 true。

于 2013-08-14T05:17:26.360 回答
0

有两种方法可以实现:

首先,您可以在 of 中定义以下属性AndroidManifest.xml

android:windowSoftInputMode="stateVisible|adjustResize"

其次,您可以将滚动视图添加为整个视图的父视图。

于 2013-08-14T04:13:34.147 回答