如何制作它以便即使键盘出现时顶栏仍然显示?
活动的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/CCLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#303e73"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.8"
android:background="#303e73">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.5">
<ImageButton
android:id="@+id/backbtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@+id/chatTV"
android:layout_toStartOf="@+id/chatTV"
android:background="#303e73"
android:src="@mipmap/whiteback" />
<TextView
android:id="@+id/chatTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="Chats"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF"
android:textSize="20dp"
android:textStyle="normal" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:visibility="gone"
android:id="@+id/typingTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:text="LOL"
android:textColor="#FFFFFF"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_alignTop="@+id/nameTV"
android:layout_centerInParent="true" />
<TextView
android:id="@+id/nameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1.5"
android:text="Biker"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.5">
<ImageButton
android:id="@+id/optionsbtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#303e73"
android:scaleType="centerCrop"
android:padding="15dp"
android:src="@mipmap/whitedot"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="41dp"
android:layout_marginStart="41dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".3">
<ListView
android:stackFromBottom="true"
android:inputType="textMultiLine"
android:maxLines="4"
android:background="#26315c"
android:id="@+id/messagesLV"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:transcriptMode="alwaysScroll"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.8"
android:background="#303e73"
android:orientation="horizontal">
<ImageButton
android:layout_gravity="center"
android:id="@+id/addimgbtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scaleType="centerCrop"
android:padding="25dp"
android:background="#303e73"
android:src="@mipmap/whiteadd" />
<EditText
android:id="@+id/messageET"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:ems="10"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:background="#303e73"
android:gravity="center"
android:hint="Enter your Message..." />
<ImageButton
android:id="@+id/sendbtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scaleType="centerCrop"
android:padding="25dp"
android:background="#303e73"
android:src="@mipmap/whitesend" />
</LinearLayout>
答案 0 :(得分:1)
将其设为操作栏并在manifest.xml中使用:
android:configChanges="keyboardHidden|orientation|keyboard"
android:windowSoftInputMode="adjustResize"
确保你不使用:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
应该工作