I want to add fragments to my application and I installed the xamarin.android.support.v4
and other required but it gives an error
error: package
android:support.v4.view
orapp
orcontent
etc. does not exist.
I have tried on a blank project with the same results.
I am using Android 7.0 and the latest support library.
For now,i want to also add RecyclerView and CardView
To use these two controls, you need to install the Xamarin.Android.Support.v7.RecyclerView
package and Xamarin.Android.Support.v7.CardView
in your project. When you install the Xamarin.Android.Support.v7.RecyclerView
package using Nuget, the Xamarin.Android.Support.v4
package will automatically be installed.
And you can use RecyclerView
like this:
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
And so is the CardView
:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:scaleType="centerCrop" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#333333"
android:text="Caption"
android:id="@+id/textView"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="4dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
You can refer to the official document RecyclerView of Xamarin for using and customizing RecyclerView
in Xamarin.Android applications.