Я создаю четыре класса фрагментов и устанавливаю адаптер в моем ViewPager, и у меня есть один файл XML стандарта
test_fragment.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Egyptian Pyramids"
android:textSize="30sp"
android:id="@+id/textTitle"
android:textColor="@color/colorPrimary"
/>
<TextView
android:id="@+id/textDescription"
android:layout_width="match_parent"
android:layout_height="171dp"
android:padding="10dp"
android:text="@string/description"
android:textSize="12sp"
android:textColor="#000000"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/image1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/image2"/>
</LinearLayout>
</LinearLayout>
, и у меня есть четыре фрагментаКласс завершен код для пролистывания в MainActivity
FirstFragment
public class FirstFragment extends Fragment {
public FirstFragment () {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View inflate = inflater.inflate(R.layout.test_fragment, container, false);
return inflate;
}
}
как изменить атрибуты в файле test_fragment.xml
, чтобы показать при перелистывании по каждому фрагменту