2015-11-04 23 views
0

以下是該應用流機器人:片段和活動工作一起

活性=>片段

片段具有一些空的空間。當點擊片段的空白區域時,我正在訪問活動的功能。如何擺脫這一點?

這裏是我的XML代碼:

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

    <RelativeLayout 
     android:id="@+id/rl_send_email_top" 
     android:layout_width="match_parent" 
     android:layout_height="51dp" 
     android:background="@color/top_layout" > 

     <ImageView 
      android:id="@+id/iv_send_email_layout_back" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:layout_alignParentLeft="true" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="5dp" 
      android:contentDescription="@string/empty" 
      android:src="@drawable/icon_back" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/rl_send_email_middle" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/rl_send_email_top" 
     android:background="@color/white" 
     android:padding="10dp" > 

     <TextView 
      android:id="@+id/tv_send_email_layout_desc" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="10dp" 
      android:text="@string/send_email_layout_desc" 
      android:textColor="@color/forgot" 
      android:textSize="12sp" /> 

     <EditText 
      android:id="@+id/et_send_email_layout_email" 
      android:layout_width="match_parent" 
      android:layout_height="35dp" 
      android:layout_below="@+id/tv_send_email_layout_desc" 
      android:layout_marginTop="20dp" 
      android:background="@drawable/edit_text_radius_boarder" 
      android:hint="@string/send_email_layout_email" 
      android:inputType="textEmailAddress" 
      android:paddingLeft="5dp" 
      android:textSize="12sp" /> 

     <EditText 
      android:id="@+id/et_send_layout_name" 
      android:layout_width="match_parent" 
      android:layout_height="35dp" 
      android:layout_below="@+id/et_send_email_layout_email" 
      android:layout_marginTop="20dp" 
      android:background="@drawable/edit_text_radius_boarder" 
      android:hint="@string/send_email_layout_name" 
      android:inputType="text" 
      android:paddingLeft="5dp" 
      android:textSize="12sp" /> 

     <EditText 
      android:id="@+id/et_send_layout_phone" 
      android:layout_width="match_parent" 
      android:layout_height="35dp" 
      android:layout_below="@+id/et_send_layout_name" 
      android:layout_marginTop="20dp" 
      android:background="@drawable/edit_text_radius_boarder" 
      android:hint="@string/send_email_layout_phone" 
      android:inputType="phone" 
      android:paddingLeft="5dp" 
      android:textSize="12sp" /> 

     <EditText 
      android:id="@+id/et_send_layout_message" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_below="@+id/et_send_layout_phone" 
      android:layout_marginTop="20dp" 
      android:background="@drawable/edit_text_radius_boarder" 
      android:gravity="top" 
      android:hint="@string/send_email_layout_message" 
      android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine" 
      android:maxLength="2000" 
      android:maxLines="5" 
      android:minLines="5" 
      android:padding="5dp" 
      android:scrollHorizontally="false" 
      android:textSize="12sp" /> 

     <Button 
      android:id="@+id/btn_send_email_layout_submit" 
      android:layout_width="150dp" 
      android:layout_height="35dp" 
      android:layout_below="@+id/et_send_layout_message" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="30dp" 
      android:background="@color/forgot" 
      android:text="@string/send_email_layout_submit" 
      android:textColor="@color/white" 
      android:textSize="12sp" /> 
    </RelativeLayout> 

</RelativeLayout> 
+0

可以請你分享你的layout.xml文件 –

+0

嗨Neeraj辛格,請請參閱編輯的版本 – Bahu

+0

Kiran您剛剛粘貼了片段佈局xml,我要求您將主佈局合併到此佈局中。 –

回答

0

短的問題,簡短的回答。

該片段必須位於持有者的內部。

只是讓持有人Match_Parent。

希望這會有所幫助。

+0

嗨,從最初的時候我也使用match_parent持有人,但它不工作。請參閱我的問題編輯版本(我包括xml文件) – Bahu

0

,您可以訪問活動的公共方法片段像下面

((BaseActivity) getActivity()).replaceFragmentWithStack(new ReportFragment()); 

放置一些代碼,它可以幫助你更:-)

+0

我認爲他想讓他的片段不能使用活動方法 – bofredo