私が持っているこのvehicle_list_fragment_layout.xml
:この方法で私のVehicleListFragment
で使用されているボタンは表示されません
<?xml version="1.0" encoding="utf-8"?>
<!-- Layout per il fragment VehicleListFragment. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/recycler_view_fragment_layout"/>
<Button
android:id="@+id/btnAddVehicle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="+"/>
</LinearLayout>
:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.vehicle_list_fragment_layout, container, false);
btnStartActivity = (Button) rootView.findViewById(R.id.btnAddVehicle);
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
mLayoutManager = new LinearLayoutManager(getActivity());
setRecyclerViewLayoutManager(LayoutManagerType.LINEAR_LAYOUT_MANAGER);
initAdapter();
mRecyclerView.setAdapter(mAdapter);
setButtonClickListener();
return rootView;
}
問題はRecyclerView
が正しく示されたが、私のしていることですbtnAddVehicle
は表示されません。
これはactivity_vehicle_layout.xml
、私のVehicleListFragment
をホストActivity
のレイアウトです:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
tools:context="clyky.cartracker.activities.VehicleActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/vehicleContainer">
</FrameLayout>
</android.support.constraint.ConstraintLayout>
私は私のフラグメントのコンテナとしてvehicleContainer
使用。 ありがとうございます!
EDIT
これは私のrecycler_view_fragment_layout
です:
<?xml version="1.0" encoding="utf-8"?>
<!-- Layout per un fragment che contiene una RecyclerView -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:id="@+id/recyclerView">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
あなたのボタン'recycler_view_fragment_layout'レイアウトの下にあります。 – Stanojkovic
@Stanojkovic私はそうは思わない: 'vehicle_list_fragment_layout'を' ScrollView'でラップし、私のボタンはまだ表示されていません。 – Clyky
'ScrollView'の高さを確認してください。 – Stanojkovic