我在Android即时聊天工作的Application.In聊天活动,我使用的是FrameLayout里。继是XML文件:无法隐藏的FrameLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FCAB26"
android:orientation="vertical"
android:weightSum="1">
<ListView
android:id="@+id/list_view_messages"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".60"
android:background="@null"
android:divider="@null"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"></ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight=".10"
android:orientation="horizontal"
android:weightSum="1">
<ImageView
android:id="@+id/imgSmile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".10"
android:src="@drawable/ic_msg_panel_smiles"
android:layout_gravity="center_vertical"
android:layout_marginRight="-10sp"/>
<com.rockerhieu.emojicon.EmojiconEditText
android:id="@+id/edtMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:hint="Enter Message"
android:layout_weight=".60"></com.rockerhieu.emojicon.EmojiconEditText>
<Button
android:id="@+id/btnSendMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight=".30"
android:gravity="center"
android:onClick="onClick"
android:text="Send Message" />
</LinearLayout>
<FrameLayout
android:id="@+id/emojicons"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".30"
android:visibility="gone" />
我已经设置了可视性框架已经消失,但它仍然占据着该区域。我希望FrameLayout在开始时不占用空间.ImageView,EditText和Send Message按钮应位于屏幕的底部。单击ImageView时,会显示表情符号面板,并且软键盘被隐藏,我已经使用了以下代码:
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hideKeyboard(); // hiding the keyboard
showEmojiPopUp(!showEmoji);
}
});
// Displaying the FrameLayout containing the list of Emoticons
public void showEmojiPopUp(boolean showEmoji) {
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.emojicons);
frameLayout.setVisibility(View.VISIBLE);
}
// Hiding the FrameLayout containing the list of Emoticons
public void hideEmojiPopUp(boolean hideEmoji) {
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.emojicons);
frameLayout.setVisibility(View.INVISIBLE);
}
它工作正常。所以我的问题是如何设置我的框架在活动创建时不可见。它应该显示在clickinh图像视图上。软键盘和FameLayout的高度应该相同。Screenshots给出下面:
1.Screenshot
2.在点击图像视图
请帮我解决这个问题。
我认为在这种情况下,你不应该在这种情况下使用的重量。试着给它固定高度 –
怎么样'setVisibility(View.GONE)' –