E
E
Eugene2015-05-27 11:09:15
Android
Eugene, 2015-05-27 11:09:15

Is it possible to use custom View on Fragment?

How to fasten a custom View that is inherited from View or SurfaceView to Fragment, is it necessary to draw graphics?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Emin, 2015-05-27
@jenchen12

Easily:
Inherit from the desired view
In layout:

<az.dgtl.egg.ui.widget.recycler.RestaurantCollectionView
            android:id="@+id/restaurant_collection_view"
            style="@style/Widget.Egg.CollectionView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

If necessary, get access in the activity\fragment:
@InjectView(R.id.restaurant_collection_view) RestaurantCollectionView mCollectionView;

S
swba, 2015-05-27
@swba

Custom views are inserted into layouts like this:

<view
        class="blah.bla_blah.ViewCanvas"
        android:id="@+id/canvas"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

Or is that not what you meant? And the word "fasten" can be understood in different ways :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question