我的xml代码中有这个布局:
<?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">
<ImageView
android:id="@+id/MainBg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop" />
<RelativeLayout
android:id="@+id/InboxTitleLyout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/PlayerImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/silhouette_small" />
<TextView
android:id="@+id/Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dip"
android:layout_marginLeft="10dip"
android:layout_marginTop="3dip"
android:textColor="@android:color/black"
android:layout_toRightOf="@+id/PlayerImage"
android:layout_alignTop="@+id/PlayerImage" />
<Button
android:id="@+id/BuddyBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/invite_friends_btn"
android:lines="1"
android:textColor="#ffffff"
android:gravity="center" />
</RelativeLayout>
<LinearLayout
android:id="@+id/NewMessagelayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:focusable="true"
android:focusableInTouchMode="true">
<EditText
android:id="@+id/EditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLength="140" />
<Button
android:id="@+id/ReplyBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadingEdge="none"
android:cacheColorHint="#00000000"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideInset"
android:layout_below="@id/InboxTitleLyout"
android:layout_above="@id/NewMessagelayout"
android:scrollbarSize="5dip"
android:smoothScrollbar="true"
android:listSelector="#00000000"
android:background="@android:color/white" />
<LinearLayout
android:id="@+id/android:empty"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_below="@id/InboxTitleLyout"
android:background="@android:color/white"
android:gravity="center">
<TextView
android:id="@+id/EmptyListMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
<TextView
android:id="@+id/EmptyListBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
以下是我正在设置布局的代码:
int editHeight = (int)(screenHeight * 0.12f);
editHeight = (editHeight < 20) ? editHeight = 20 : editHeight;
LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams((int)(editTextBoxPercentage * screenWidth),editHeight);
replyET.setLayoutParams(editParams);
LinearLayout.LayoutParams replyParams = new LinearLayout.LayoutParams((int)(replyBtnPercentage * screenWidth),editHeight);
sendReply.setLayoutParams(replyParams);
当我开始这个活动时,我没有看到NewMessageLayout Linearlayout,但是当我按下它的位置时,键盘弹出,我可以输入文本 - 它接收事件。 我不明白为什么布局没有绘制。
感谢。