I want to use databinding for recyclerview. I created a model with BindignAdapter annotation. But after that I don't know what should I do and I didn't find any solution.
I want to set some data for recyclerview adapter and set the adapter as recyclerview adapter and show data in the recyclerview.
This is my MainActivity XML file(This line has an error:android:recyclerUser="#{dog.recyclerViewBinder()}"):
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="dog"
type="com.hooman.databinding.DogModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:recyclerUser="#{dog.recyclerViewBinder()}"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
This is my model class:
class DogModel(var dogName:String, var dogImage:String?, var dogBreed:String,var context: Context){
#BindingAdapter("android:loadImage")
fun loadImage(imageView: ImageView,dogImage:String?){
Picasso.get().load(dogImage).into(imageView)
}
#BindingAdapter("android:recyclerUser")
fun recyclerViewBinder(recyclerView: RecyclerView,dogList: MutableList<DogModel>){
var dogAdapter = DogAdapter(dogList)
recyclerView.layoutManager = LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false)
recyclerView.adapter = dogAdapter
}
}
This is recyclerview's adapter:
class DogAdapter(var dogList:List<DogModel>): RecyclerView.Adapter<DogAdapter.DogViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DogViewHolder {
val view = DataBindingUtil.inflate<RvDogItemBinding>(LayoutInflater.from(parent.context),R.layout.rv_dog_item,parent,false)
return DogViewHolder(view)
}
override fun onBindViewHolder(holder: DogViewHolder, position: Int) {
holder.view.dog = dogList[position]
holder.view.executePendingBindings()
}
override fun getItemCount(): Int {
return dogList.size
}
inner class DogViewHolder(var view: RvDogItemBinding) : RecyclerView.ViewHolder(view.root)
}
This is rv_dog_item.xml file:
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="dog"
type="com.hooman.databinding.DogModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
app:cardCornerRadius="10dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/img_dog"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:loadImage="#{dog.dogImage}"/>
<TextView
android:id="#+id/txt_dogName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="#id/img_dog"
app:layout_constraintEnd_toStartOf="#id/img_dog"
android:textSize="22sp"
android:padding="10dp"
android:textColor="#color/black"
android:text="#{dog.dogName}"/>
<TextView
android:id="#+id/txt_dogBreed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#id/txt_dogName"
app:layout_constraintStart_toStartOf="#id/txt_dogName"
app:layout_constraintEnd_toEndOf="#id/txt_dogName"
android:layout_marginTop="32dp"
android:text="#{dog.dogBreed}"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
And this is mainActivity class:
class MainActivity : AppCompatActivity() {
lateinit var binding:ActivityMainBinding
lateinit var adapter:DogAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//setContentView(R.layout.activity_main)
binding = DataBindingUtil.setContentView(this,R.layout.activity_main)
var model = DogModel("Foo Dog",null,"Husky",this)
binding.dog = model
}
}
So what I should I do next and what did I make a mistake?
Related
I'm trying to display a list of files and folders using a RecyclerView.
Here is the Adapter and the ViewHolder :
class FilesRecyclerViewAdapter(private val files: Array<File>) : RecyclerView.Adapter<FilesRecyclerViewAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.fragment_file_item, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = files[position]
holder.icon.setImageResource(if (item.isDirectory) R.drawable.folder else R.drawable.file)
holder.fileName.text = item.name
}
override fun getItemCount(): Int = files.size
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val icon: ImageView = view.findViewById(R.id.icon)
val fileName: TextView = view.findViewById(R.id.fileName)
}
}
The layout for a single item in the list (R.layout.fragment_file_item) :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/fileItem"
android:layout_width="match_parent"
android:layout_height="#dimen/file_item_height">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_launcher_foreground" />
<TextView
android:id="#+id/fileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:text="Element"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#+id/icon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
And this is how it's included into the main activity :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/fileSystem"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Finally the code in the onCreate function of the main activity :
private lateinit var fileSystem: RecyclerView
// Later in the code
fileSystem = findViewById(R.id.fileSystem)
fileSystem.layoutManager = LinearLayoutManager(this)
fileSystem.adapter = FilesRecyclerViewAdapter(Environment.getExternalStorageDirectory().listFiles())
I expected to have a list of items with the icon on the left and the name of the folder slighly to the right like on the item layout preview :
Instead, I have this mess :
What did I do wrong ?
app:layout_constraintHorizontal_bias="0.5" makes your RecyclerView start on 50% of view.
Remove it, if you dont need them
The RecyclerView shows simple items. Each item has one TextView inside FrameLayout. TextView has no any paddings, but in some cases they appears unexpectedly. The picture below shows that the padding appears immediately after opening the keyboard. The padding appears only if the text contains newline characters. How to fix it ?
MainActivity.kt
class MainActivity : AppCompatActivity() {
lateinit var adapter : MyAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val recyclerView : RecyclerView = findViewById(R.id.recyclerView)
val button : Button = findViewById(R.id.button)
adapter = MyAdapter();
recyclerView.adapter = adapter;
button.setOnClickListener {
adapter.notifyDataSetChanged()
}
}
}
class MyViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
val textView: TextView;
init {
textView = view.findViewById(R.id.txt)
}
}
class MyAdapter : RecyclerView.Adapter<MyViewHolder>() {
private val data = listOf("Text without \\n ", "multiline\ntext")
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
MyViewHolder(LayoutInflater.from(parent.context)
.inflate(R.layout.list_item, parent, false))
override fun getItemCount() = data.size;
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
holder.textView.text = data[position]
}
}
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:background="#android:color/holo_blue_light"
android:id="#+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:text="notifyDataSetChanged"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:id="#+id/button"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"
/>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="#+id/button"
android:id="#+id/recyclerView"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
app:layout_constraintStart_toEndOf="#+id/button" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
I just started Android development using kotlin lang and facing issue as mentioned below with code
Unable to get click event when using Android ListAdapter with data binding in Kotlin.
Source Code:
list_item_shopping_list_name.xml:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="clickListener"
type="android.view.View.OnClickListener" />
<variable
name="shoppingListName"
type="com.vp.shoppinglist.database.entity.ShoppingListName" />
</data>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="70dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:onClick="#{clickListener}">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:text="#{shoppingListName.name}" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
Adapter Code:
class ShoppingListNameAdapter(var context: Context) :
ListAdapter<ShoppingListName, ShoppingListNameAdapter.ViewHolder>(ShoppingListNameDiffCallback()) {
private val TAG = javaClass.simpleName
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
var inflater = LayoutInflater.from(parent.context)
var binding = ListItemShoppingListNameBinding.inflate(inflater, parent, false)
return ViewHolder(binding)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
getItem(position).let { shoppingListName ->
holder.apply {
bind(createOnClickListener(shoppingListName), shoppingListName)
itemView.tag = holder
}
}
}
class ViewHolder(var binding: ListItemShoppingListNameBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(listener: View.OnClickListener, item: ShoppingListName) {
binding.apply {
with(binding) {
clickListener = listener
shoppingListName = item
executePendingBindings()
}
}
}
}
private fun createOnClickListener(shoppingListName: ShoppingListName): View.OnClickListener {
return View.OnClickListener {
Log.e("Click", "==========OnClickListener")
Toast.makeText(context, "Clicked : ${shoppingListName.name}", Toast.LENGTH_LONG).show()
}
}
class ShoppingListNameDiffCallback : DiffUtil.ItemCallback<ShoppingListName>() {
override fun areItemsTheSame(oldItem: ShoppingListName, newItem: ShoppingListName): Boolean {
return oldItem.name == newItem.name
}
override fun areContentsTheSame(oldItem: ShoppingListName, newItem: ShoppingListName): Boolean {
return oldItem.equals(newItem)
}
}
}
Can someone help me to fix my issue. Kindly let me know if any other information required about code/project.
Thanks in advance
You can set your listener at you ViewModel like this
interface YourViewModel {
fun itemClicked()
}
class YourViewModelImpl : YourViewModel {
override fun itemClicked() {
// your code after clicked
}
}
and then your xml is
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="YourViewModel" />
<variable
name="shoppingListName"
type="com.vp.shoppinglist.database.entity.ShoppingListName" />
</data>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="70dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:onClick="#{() -> viewModel.itemClicked(shoppingListName)}">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:text="#{shoppingListName.name}" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
and then you need only set you listener in viewHolder for dataBinding
The problem is that when the soft keyboard appears, it overlaps the recyclerView. But I want my soft keyboard just push recycler to the top, to be above the keyboard, like with windowSoftInputMode="adjustPan".
But adjustPan is not the option because I need my tool bar.
I have tried adjustResize already, but no luck.
Main activity layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
>
<include
layout="#layout/toolbar_layout"
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="#+id/recyc"
app:layout_constraintBottom_toTopOf="#+id/message_edit_text"
app:layout_constraintTop_toBottomOf="#+id/toolbar_layout"/>
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/message_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Adapter item layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Here is my MainActivity code, there is the only onCreate method
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
recyc.layoutManager = LinearLayoutManager(this)
val adapter = MyAdapter(
arrayOf("sd","sd2","sd2","sd2","sd2","s2d","s2d","sd",
"sd2","s2d","s2d","sd5","s8d","67sd","s76d")
)
recyc.adapter = adapter
}
Here is my adapter class
class MyAdapter(private val myDataset: Array<String>) :
RecyclerView.Adapter<MyAdapter.MyViewHolder>() {
class MyViewHolder(val view: View) :
RecyclerView.ViewHolder(view)
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): MyAdapter.MyViewHolder {
val textView = LayoutInflater.from(parent.context)
.inflate(R.layout.container, parent, false)
return MyViewHolder(textView)
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int)
{ holder.itemView.textView.text = myDataset[position] }
override fun getItemCount() = myDataset.size
}
I have a simple question , I have a RecyclerView with 10 items, an Horizontal Scroll with paging Activated and my items appears in the middle like this :
What do I want now it's to have this. As you can see the next item is visible on the screen :
Here is my xml file :
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:src="#drawable/square_elem"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
My MainActivity :
class MainActivity : AppCompatActivity() {
{
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
recyclerInit()
}
fun recyclerInit()
{
val list : ArrayList<String> = ArrayList()
for (i in 1..10) {
list.add("$i")
}
recyclerview.layoutManager = LinearLayoutManager(this,
LinearLayoutManager.HORIZONTAL, false)
recyclerview.setHasFixedSize(true)
recyclerview.adapter = RecyclerAdapter(list)
val snapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(recyclerview)
}
}
And This is my Adapter :
class RecyclerAdapter(val list: ArrayList<String>) : RecyclerView.Adapter<RecyclerAdapter.ViewHolder>()
{
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view: View = LayoutInflater.from(parent.context).inflate((R.layout.box_elem), parent, false)
return ViewHolder(view)
}
override fun getItemId(position: Int): Long {
return position.toLong()
}
override fun getItemViewType(position: Int): Int {
return position
}
override fun getItemCount(): Int {
return list.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.image.setImageResource(R.drawable.original_box)
holder.itemView.setOnClickListener(View.OnClickListener {
removeElemAt(position);
})
}
fun removeElemAt(position: Int) {
list.removeAt(position)
notifyItemRemoved(position)
notifyItemRangeChanged(position, list.size)
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
var image: ImageView = itemView.findViewById(R.id.box_elem)
}
}
Try this code
RecyclerView xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
YourItem xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rl"
android:layout_width="YourOption"
android:layout_height="YourOption">
<ImageView
android:id="#+id/img"
android:layout_width="YourOption"
android:layout_height="YourOption"
android:gravity="YourOption"
android:scaleType="YourOption"
/>
</RelativeLayout>
change your layout with this code
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:src="#drawable/square_elem"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>