Skip to content

Instantly share code, notes, and snippets.

@JolandaVerhoef
Created October 17, 2018 11:28
Show Gist options
  • Save JolandaVerhoef/8d7a0ef7d905d8aeb0d3586658bb6b6b to your computer and use it in GitHub Desktop.
Save JolandaVerhoef/8d7a0ef7d905d8aeb0d3586658bb6b6b to your computer and use it in GitHub Desktop.
Sample project with failing preview
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.jolandaverhoef.test.TestView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
package com.jolandaverhoef.test
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
package com.jolandaverhoef.test
import android.content.Context
import android.support.constraint.ConstraintLayout
import android.util.AttributeSet
import android.view.View
class TestView : ConstraintLayout {
constructor(context: Context) : super(context) {
View.inflate(context, R.layout.view_test, this)
}
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
View.inflate(context, R.layout.view_test, this)
}
constructor(context: Context, attrs: AttributeSet?, attributeSetId: Int) : super(context, attrs, attributeSetId) {
View.inflate(context, R.layout.view_test, this)
}
}
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:parentTag="android.support.constraint.ConstraintLayout">
<TextView
android:id="@+id/text_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="test"/>
</merge>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment