How is this View inflated? Is TextView a field of ...
# android
t
How is this View inflated? Is TextView a field of LinearLayout or gets moved somewhere?
Copy code
xml
<LinearLayout xmlns:android="<http://schemas.android.com/apk/res/android>"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/item_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>
google 1
😶 4
stackoverflow 1
l
Not sure what else you are asking, but the text view becomes a child of the linear layout during inflation. Usually you would access views via
findViewById()
in your activity or fragment.
t
I meant like, after the TextView is inflated(turned into Java objects), does it get added as a property of the LinearLayout object or not? Maybe added into a data structure inside LinearLayout?
k
If you're interested in how this works under the hood, you'd look at the source code of LayoutInflater (around lines 627-690) and ViewGroup (around lines 5338-5366). The 😶 tag means that this, though, has nothing to do with the purpose of this channel, and questions like this do not get much traction 99% of the time.
l
Yep, you can use cs.android.com to search for sources. The TextView ends up added to an array of views inside the LinearLayout, check the source!
👍 1
t
I found it in ViewGroup source code at the location specified. It's my first time asking question here, so I guess I used the channel incorrectly. Still, thanks for the help.
h
@Luis Thats a great website, I never there is a site like this
👍 1