mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-09 04:32:27 -04:00
Fix[side_dialog]: make the dialog scale properly with wrap_content
This commit is contained in:
parent
924c33cb2c
commit
b7fa7eb9eb
@ -4,7 +4,6 @@ import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -14,19 +13,17 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.IntegerRes;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
|
||||
import net.kdt.pojavlaunch.R;
|
||||
|
||||
public class SideDialogView<T extends View> {
|
||||
|
||||
private final ConstraintLayout mDialogLayout;
|
||||
private final ViewGroup mDialogLayout;
|
||||
private final DefocusableScrollView mScrollView;
|
||||
protected final T mDialogContent;
|
||||
private final int mMargin;
|
||||
@ -39,7 +36,7 @@ public class SideDialogView<T extends View> {
|
||||
|
||||
public SideDialogView(Context context, ViewGroup parent, @LayoutRes int layoutId) {
|
||||
// Inflate layouts
|
||||
mDialogLayout = (ConstraintLayout) LayoutInflater.from(context).inflate(R.layout.dialog_side_dialog, parent, false);
|
||||
mDialogLayout = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.dialog_side_dialog, parent, false);
|
||||
mScrollView = mDialogLayout.findViewById(R.id.side_dialog_scrollview);
|
||||
mStartButton = mDialogLayout.findViewById(R.id.side_dialog_start_button);
|
||||
mEndButton = mDialogLayout.findViewById(R.id.side_dialog_end_button);
|
||||
|
@ -1,30 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- FIXME: If I use wrap content for the scrollview, it goes overboard -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<LinearLayout
|
||||
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="@dimen/_280sdp"
|
||||
android:layout_marginVertical="@dimen/padding_heavy"
|
||||
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/background_control_editor"
|
||||
>
|
||||
|
||||
<com.kdt.DefocusableScrollView
|
||||
android:id="@+id/side_dialog_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
||||
app:layout_constraintBottom_toTopOf="@+id/side_dialog_start_button"
|
||||
app:layout_constraintTop_toBottomOf="@id/side_dialog_title_textview"
|
||||
|
||||
tools:background="@color/background_status_bar">
|
||||
<!-- The content is inflated here -->
|
||||
</com.kdt.DefocusableScrollView>
|
||||
|
||||
android:background="@drawable/background_control_editor">
|
||||
<TextView
|
||||
android:id="@+id/side_dialog_title_textview"
|
||||
style="@style/TextAppearance.AppCompat.Large"
|
||||
@ -37,7 +22,6 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Quick settings"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<View
|
||||
android:id="@+id/side_dialog_title_divider"
|
||||
style="@style/ThickDivider"
|
||||
@ -45,35 +29,44 @@
|
||||
android:paddingHorizontal="@dimen/padding_moderate"
|
||||
android:visibility="gone"
|
||||
|
||||
app:layout_constraintTop_toBottomOf="@id/side_dialog_title_textview"
|
||||
|
||||
tools:visibility="visible"
|
||||
/>
|
||||
<com.kdt.DefocusableScrollView
|
||||
android:id="@+id/side_dialog_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
tools:background="@color/background_status_bar">
|
||||
<!-- The content is inflated here -->
|
||||
</com.kdt.DefocusableScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/side_dialog_start_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/side_dialog_start_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:visibility="visible"
|
||||
|
||||
tools:visibility="visible"
|
||||
tools:text="Cancel"
|
||||
/>
|
||||
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:visibility="visible"
|
||||
tools:text="Cancel"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/side_dialog_end_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
<Button
|
||||
android:id="@+id/side_dialog_end_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:visibility="visible"
|
||||
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
tools:visibility="visible"
|
||||
tools:text="Confirm"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
tools:text="Confirm"
|
||||
tools:visibility="visible"
|
||||
tools:ignore="RelativeOverlap" />
|
||||
<!-- Appears to be no way to properly fix this, and I'm not super fond of child ConstraintLayouts -->
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user