"android.view.View cannot be cast to android.view.ViewGroup" exception
I know i am late to the party, but just in case some is banging his head for same problem, here is one possible solution that worked for me when i was trying to add zoom functionality in my pager adapter images. Info: this is not the exact answer, but a possible solution for those who are facing the same problem. I am posting this because i didn't fount this solution approach anywhere in stackOverflow
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/head_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/head_image" />
</RelativeLayout>
In the above code, just Replace <ImageView
with <com.yourPackage.TouchImageView
.
TouchImageView (or any other class) is a custom class (you need to make)which should extend android.support.v7.widget.AppCompatImageView
I think you should use
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgTile"
android:src="@drawable/tile_background"
android:contentDescription="@string/CD_TILE_BACKGROUND_IMAGE"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ImageView>
</LinearLayout >
as View does not have any function like add(other_view) you can add a view in ViewGorup ....