Hello StackOverflow users!
I'm trying to do someting complicated (for a noob like me XD) and I have some questions.
How can I set my main screen buttons position form a preference screen? Like, if I have 2 buttons to inverse their position...
I tried to do with the code below in kotlin (please don't judge me, already told u I'm noob af) but I wanna have an idea how to make this wotk. XD
findPreference<Preference>("buttonpositions")!!.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { preference: Preference, _: Any? ->
val checked = (preference as CheckBoxPreference).isChecked
if(!checked) {
val myBtn = R.id.cleanBtn as Button
myBtn.setPadding(0, 100, 0, 0)
}
true
}
and the buttons is something like this:
<com.google.android.material.button.MaterialButton
style="@style/Widget.Material3.Button.UnelevatedButton"
android:id="@+id/cleanBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
android:minWidth="0dp"
app:layout_rowWeight="1"
android:tooltipText="@string/tooltip_clean_button"
app:iconGravity="top"
app:icon="@drawable/ic_broom"
app:iconTint="@android:color/system_accent1_400"
android:textColor="@android:color/system_accent1_400"
android:text="@string/clean"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.Material3.Button.UnelevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:id="@+id/analyzeBtn"
app:iconGravity="top"
app:icon="@drawable/ic_search"
android:tooltipText="@string/analyze_tooltip"
app:iconTint="@android:color/system_accent1_700"
android:textColor="@android:color/system_accent1_700"
android:text="@string/analyze"
android:minWidth="0dp"
app:backgroundTint="@android:color/transparent"/>
First. I'm preety sure my "code" isn't right composed + idk if I need to add someting to buttons itself.
Thanks for your time :D