我在我的应用中使用自定义标题栏,当用户点击editext进入文本键盘打开并隐藏标题栏时...
这是我的主要xml布局:
<LinearLayout
android:id="@+id/layoutCommonLikesHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_alignParentTop="true"
android:background="@drawable/header"
android:orientation="vertical" >
<TextView android:id="@+id/tvCommonLikesHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You're now chatting with a random stranger. Say hi!"
android:textSize="12sp"
android:paddingBottom="3dp"
android:gravity="center_horizontal"
android:textStyle="normal|bold"
android:textColor="@android:color/primary_text_dark"/>
<TextView android:id="@+id/tvCommonLikes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You both like Harry"
android:textSize="13sp"
android:paddingBottom="4dp"
android:gravity="center_horizontal"
android:textStyle="normal|bold"
android:textColor="@android:color/primary_text_dark"/>
</LinearLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/layoutInterest"
android:layout_below="@+id/layoutCommonLikesHeader"
android:divider="@android:color/background_dark"
android:dividerHeight="0dp"
android:isScrollContainer="false"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:smoothScrollbar="true"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" >
</ListView>
<LinearLayout
android:id="@+id/layoutInterest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_above="@+id/layoutCheckBox"
android:orientation="vertical" >
<EditText
android:id="@+id/etCommonInterest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="eg:- Music,Friend,Old."
android:textSize="15sp"
android:visibility="gone"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textStyle="italic"
/>
</LinearLayout>
<LinearLayout android:id="@+id/layoutCheckBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_above="@+id/Status"
android:orientation="horizontal">
<CheckBox android:id="@+id/mCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:visibility="gone"/>
<TextView
android:id="@+id/tvAddInterest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:visibility="gone"
android:text="Find stranger with common interest."
android:gravity="center_horizontal"
android:textStyle="normal|bold"
android:textColor="@android:color/tertiary_text_light"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/Status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_above="@+id/form"
android:orientation="horizontal" >
<TextView
android:id="@+id/tvStatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:gravity="center_horizontal"
android:textColor="@android:color/tertiary_text_light"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/form"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal" >
<Button
android:id="@+id/btStopStart"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:textColor="@android:color/tertiary_text_light"
android:textSize="14dp" />
<EditText android:id="@+id/ChatBoxText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:ems="10"
android:layout_alignParentBottom="true"
android:imeOptions="actionSend"
android:singleLine="true"
android:inputType="text"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:hint="type message..."
android:textColor="@android:color/primary_text_light"
android:textSize="16sp"/>
<Button
android:id="@+id/btSendText"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/form"
android:text="Send"
android:textColor="@android:color/tertiary_text_light"
android:textSize="15dp" />
</LinearLayout>
这是我的清单。我也在这里改了但是自定义标题栏仍然不可见。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.randomchat"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/TitleBarTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>