Skip to content

Commit

Permalink
fix: remove hardcoded layout params from category selector
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq committed Dec 16, 2024
1 parent 81c9b57 commit b05b7f9
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,23 +348,16 @@ private void showCategorySelectorDialog(List<String> choices, TextInputEditText
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));

ListView listView = new ListView(context);
ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_single_choice, choices);
listView.setAdapter(adapter);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setItemChecked(choice.get(), true);

int maxHeightPx = dpToPx(350);

LinearLayout.LayoutParams listParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
maxHeightPx
);

listParams.setMargins(0, dpToPx(15), 0, dpToPx(10));
listView.setLayoutParams(listParams);

if (listView.getParent() != null) {
((ViewGroup) listView.getParent()).removeView(listView);
}
Expand Down

0 comments on commit b05b7f9

Please sign in to comment.