2013-08-06 82 views
0

我知道如何用操作栏选项卡导航来构建活动。但我需要知道如何用这样一个片段tabhost覆盖键盘(例如三个不同类型的表情组织在标签中)。任何代码或教程链接将非常感激!用键盘片段代替键盘

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#f6f6f8"> 


<ListView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/listViewChat" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" 
     android:layout_alignTop="@+id/LinearLayout1" android:layout_above="@+id/LinearLayout1" 
     android:divider="@null" android:dividerHeight="0dp" android:clickable="false"/> 

<LinearLayout 
     android:id="@+id/LinearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" 
     android:background="@drawable/riwa_in" 
     > 

code removed here is a custom view (copyright issue) 

<LinearLayout 

     android:layout_width="match_parent" 
     android:layout_height="50dp" 

     android:orientation="horizontal" 
     > 



    <ImageButton 
      android:id="@+id/addContentChat" 
      android:layout_width="45dp" 
      android:layout_height="match_parent" 
      android:background="@null" 
      android:longClickable="true" 
      android:padding="8dp" 
      android:src="@drawable/emo_mod_im_happy" /> 

    <EditText 
      android:id="@+id/mesText" 
      android:layout_width="0dp" 
      android:layout_height="37dp" 
      android:layout_marginTop="7dp" 
      android:layout_weight="0.57" 
      android:autoLink="all" 
      android:hint="@string/messageHint" 
      android:inputType="textMultiLine" 
      android:linksClickable="true" 
      android:maxHeight="50dp" 
      android:maxLines="4" 
      android:paddingLeft="8dp" 
      android:paddingRight="5dp" 
      android:textColor="#000000" 
      android:textSize="15sp" 
      android:textStyle="normal" 

      android:typeface="sans" > 

     <requestFocus /> 
    </EditText> 

    <ImageButton 
      android:id="@+id/sendButton" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:longClickable="true" 
      android:src="@drawable/ic_send_holo_light" android:layout_gravity="center_vertical" 
      android:background="@null" android:focusable="false" android:scaleType="center" 
      /> 


</LinearLayout> 


</LinearLayout> 

提前感谢!

回答

2

为什么你不把片段放在屏幕的底部并使其覆盖其他任何东西?如果您发布布局,我可以给你更准确的答案。但是,例如尝试这样的事情:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    // Put everything else which is supposed to be in your layout here 

    <Fragment 
     android:id="@+id/frmBottomOverlay" 
     android:name="com.example.fragment.YourBottomOverlayFragment" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visible="gone" 
     android:layout_alignParentBottom="true" /> 
</RelativeLayout> 

然后,如果你想显示在你只需要设置片段View.VISIBLE的知名度编程底部的片段。

隐藏键盘当您显示底部的片段试试这个:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0); 
+0

如果覆盖一切,它也覆盖键盘?我编辑了我的questoion,现在包括xml –

+0

不,您可以在将片段的可见性设置为View.VISIBLE时隐藏键盘。我将编辑我的答案,包括如何隐藏键盘。 –

+0

thx我已经得到了代码如何隐藏键盘。我应该把这个片段放在我的结构顶层作为最后一点? –