我在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)' –