2016-02-25 3 views
0

Основная деятельность XMLмакет фрагмента макета Перекрытие основного вида деятельности в

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.apuroopa.homework5_apuroopa.ActionBar_Activity" 
    android:id="@+id/container"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_action_bar_" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_dialog_email" /> 

</android.support.design.widget.CoordinatorLayout> 

/// расположение cardview XML

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_margin="5dp" 
    > 


    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#fffffff0" 
     > 


     <TextView 
      android:id="@+id/title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textStyle="bold" 
      android:layout_toRightOf="@+id/selection" 

      android:layout_marginLeft="10dp" 
      /> 
     <TextView 
      android:id="@+id/description" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/title" 
      android:layout_toLeftOf="@+id/image" 

      android:layout_marginLeft="10dp"/> 

     <CheckBox 
      android:id="@+id/selection" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:clickable="false" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignTop="@id/title" 
      /> 
     <ImageView 
      android:id="@+id/image" 
      android:layout_width="80dp" 
      android:layout_height="100dp" 
      android:layout_alignParentRight="true" 
      android:scaleType="fitXY"/> 
    </RelativeLayout> 

</android.support.v7.widget.CardView> 

/// enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.apuroopa.homework5_apuroopa.ActionBarFragment"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_action_bar_fragment" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_dialog_email" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/cardList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     /> 
</android.support.design.widget.CoordinatorLayout> 


//Main Activity java 

public class ActionBar_Activity extends AppCompatActivity implements Fragment_RecyclerView.OnListItemSelectedListener 
{ 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_action_bar_); 
     Fragment mcontent = Fragment_RecyclerView.newInstance(0); 
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 

     ActionBar actionBar=getSupportActionBar(); 
     Fragment_RecyclerView FR = new Fragment_RecyclerView(); 
     getSupportFragmentManager().beginTransaction().add(R.id.container,mcontent) 
       //(Fragment_RecyclerView.newInstance(0)," ") 
       .commit(); 
    } 

У меня есть файл меню надувается Мероприятия. К активности добавляется Recyclerview fragment. Каждая строка в фрагменте recyclerview состоит из макета карты. Мой recyclerview перекрывает параметры меню, как показано на рисунке. Панель инструментов помещается над recyclerview в файле макета.

+0

Обратите внимание на «android: layout_gravity =" bottom | right "" в FloatingActionButton. Или разместите FloatingActionButton ниже RecyclerView и попробуйте. – user1182217

ответ

0

Put CardView контейнер в RelativeLayout:

<RelativeLayout...> 
    <android.support.v7.widget.CardView .....> 
    </android.support.v7.widget.CardView> 
</RelativeLayout> 
0

Первый дать идентификатор android.support.design.widget.AppBarLayout

Тогда

<android.support.v7.widget.RecyclerView 
    android:[email protected]/app_bar_layout_id/> 
Смежные вопросы