| @@ -88,18 +88,8 @@ class MainActivity : AppCompatActivity() { | |||||
| for (row in 0..1) { | for (row in 0..1) { | ||||
| for (col in 0..1) { | for (col in 0..1) { | ||||
| val newFrame = inflater.inflate(R.layout.layout_button, null) | |||||
| // newFrame.findViewById<ProgressBar>(R.id.progress_bar) | |||||
| // newFrame.findViewById<TextView>(R.id.text_view_button) | |||||
| val params = GridLayout.LayoutParams() | |||||
| params.columnSpec = GridLayout.spec(col, 1, 1.0f) | |||||
| params.rowSpec = GridLayout.spec(row, 1, 1.0f) | |||||
| params.width = 0 | |||||
| params.height = 0 | |||||
| newFrame.layoutParams = params | |||||
| parent.addView(newFrame) | |||||
| val soundButton = SoundButton(this, col, row) | |||||
| parent.addView(soundButton) | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,19 @@ | |||||
| package de.mlte.soundboard | |||||
| import android.content.Context | |||||
| import android.view.View | |||||
| import android.widget.FrameLayout | |||||
| import android.widget.GridLayout | |||||
| class SoundButton : FrameLayout { | |||||
| constructor(context: Context, col: Int, row: Int) : super(context) { | |||||
| View.inflate(context, R.layout.layout_button, this) | |||||
| val params = GridLayout.LayoutParams() | |||||
| params.columnSpec = GridLayout.spec(col, 1, 1.0f) | |||||
| params.rowSpec = GridLayout.spec(row, 1, 1.0f) | |||||
| params.width = 0 | |||||
| params.height = 0 | |||||
| layoutParams = params | |||||
| } | |||||
| } | |||||
| @@ -1,7 +1,7 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
| <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:padding="2dp"> | android:padding="2dp"> | ||||
| <ProgressBar | <ProgressBar | ||||
| android:id="@+id/progress_bar" | android:id="@+id/progress_bar" | ||||