2016-05-24 3 views
0

MainActivityレイアウトのボタンがあります。フラグメントを開始するときに、このボタンをフラグメント要素で表示したいのですが、フラグメント要素のみが表示されます。私が間違っていることは何ですか?MainActivityレイアウトのボタンはフラグメントレイアウトで表示されません

MainAcivityレイアウト

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".ui.MainActivity"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:id="@+id/linear_layout"> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="@dimen/button_height" 
     android:id="@+id/send_button" 
     android:text="SEND" 
     android:background="@color/circleBackground"/> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="@dimen/button_height" 
     android:layout_marginLeft="2dp" 
     android:text="SAVE" 
     android:id="@+id/save_button" 
     android:background="@color/circleBackground"/> 

    <ImageButton 
     android:layout_width="100dp" 
     android:layout_height="@dimen/button_height" 
     android:src="@drawable/ic_settings_black_24dp" 
     android:background="@color/circleBackground" 
     android:layout_marginLeft="2dp"/> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="@dimen/button_height" 
     android:layout_marginLeft="2dp" 
     android:text="+" 
     android:id="@+id/post_button" 
     android:background="@color/circleBackground"/> 

</LinearLayout> 

<FrameLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 

フラグメントレイアウト(fragment_list)私は、アプリケーションがロードされているだけリストビューを参照してください、現在の瞬間に

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/mainBackground"> 

<ListView android:id="@+id/product_listview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/linear_layout" 
      android:dividerHeight="1dp" 
      android:divider="@color/circleBackground" 
      android:fastScrollEnabled="true"> 
</ListView> 

。フラグメントで :

@Override 
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 
    return inflater.inflate(R.layout.fragment_list, container,false); 
} 
+0

フラグメント番号 –

答えて

0

「主な活動であなたの親のレイアウトは、相対的なレイアウトで、あなたがいずれかを設定していないので、あなたのFrameLayout

android:layout_below="@+id/linear_layout" 
+0

ありがとう 'たくさん。それは仕事です! – Delphian

+0

いつもwc @Delphian please upvote –

0

あなたはFrameLayoutLinearLayoutに以下でなければならないことを定義する必要があります。

android:layout_below="@+id/linear_layout" 

全レイアウト

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".ui.MainActivity"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/linear_layout"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="@dimen/button_height" 
      android:id="@+id/send_button" 
      android:text="SEND" 
      android:background="@color/circleBackground"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="@dimen/button_height" 
      android:layout_marginLeft="2dp" 
      android:text="SAVE" 
      android:id="@+id/save_button" 
      android:background="@color/circleBackground"/> 

     <ImageButton 
      android:layout_width="100dp" 
      android:layout_height="@dimen/button_height" 
      android:src="@drawable/ic_settings_black_24dp" 
      android:background="@color/circleBackground" 
      android:layout_marginLeft="2dp"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="@dimen/button_height" 
      android:layout_marginLeft="2dp" 
      android:text="+" 
      android:id="@+id/post_button" 
      android:background="@color/circleBackground"/> 

    </LinearLayout> 

    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_below="@+id/linear_layout" 
     android:layout_height="wrap_content"/> 
</RelativeLayout> 
+0

フルコードをありがとうございました! – Delphian

+0

それが役に立ったら私はそれについて幸せです:) –

0

でこれを追加linear_layoutアイテムとコンテナの間に相対性理論がある場合、そのコンテナはlinear_layoutの上に表示され、見えません。 コンテナをlinear_layoutの下に置くなど、いくつかの関係を定義するだけです。

+0

ありがとうございました!私はlayout_belowを追加しました – Delphian

関連する問題