Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MvRx xml layout files not rendering in android studio #117

Closed
jQrgen opened this issue Oct 9, 2018 · 2 comments
Closed

MvRx xml layout files not rendering in android studio #117

jQrgen opened this issue Oct 9, 2018 · 2 comments

Comments

@jQrgen
Copy link

jQrgen commented Oct 9, 2018

In the example repo from AirBnBs new framework MvRx xml layout files does not render in the android studio editor as shown in the screenshot below. Neither can I make the views render in Android Studio for my own projects

enter image description here

full_screen_message.xml

    <?xml version="1.0" encoding="utf-8"?>
    <merge
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        tools:parentTag="android.widget.FrameLayout"
        >
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center"
            android:gravity="center_horizontal">
            <ImageView
                android:id="@+id/icon"
                android:layout_width="64dp"
                android:layout_height="64dp"
                android:scaleType="centerCrop"
                android:contentDescription="@string/asd" />
    
            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="@string/asdasdasdad"/>
    
        </LinearLayout>
    </merge>

FullScreenMessageView.kt:

    package com.airbnb.mvrx.todomvrx.views
    
    import android.content.Context
    import android.support.annotation.DrawableRes
    import android.util.AttributeSet
    import android.widget.FrameLayout
    import android.widget.ImageView
    import android.widget.TextView
    import com.airbnb.epoxy.ModelProp
    import com.airbnb.epoxy.ModelView
    import com.airbnb.epoxy.TextProp
    import com.airbnb.mvrx.todomvrx.todoapp.R
    
    @ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_MATCH_HEIGHT)
    class FullScreenMessageView @JvmOverloads constructor(
            context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
    ) : FrameLayout(context, attrs, defStyleAttr) {
    
        private val iconView by lazy { findViewById<ImageView>(R.id.icon) }
        private val titleView by lazy { findViewById<TextView>(R.id.title) }
    
        init {
            inflate(context, R.layout.full_screen_message, this)
        }
    
        @ModelProp
        fun setIconRes(@DrawableRes drawableRes: Int) {
            iconView.setImageResource(drawableRes)
        }
    
        @TextProp
        fun setTitle(title: CharSequence) {
            titleView.text = title
        }
    }
@qbait
Copy link

qbait commented Oct 15, 2018

Looks like buggy tools:parentTag. Works when I tried to replace it with android:parentTag

@jQrgen
Copy link
Author

jQrgen commented Oct 15, 2018

It works but Android Studio does not like it.
screen shot 2018-10-15 at 17 59 57

@jQrgen jQrgen closed this as completed Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants