Skip to content

Commit 0e4ad71

Browse files
Refine help screen edge-to-edge layout
1 parent 65d477f commit 0e4ad71

File tree

2 files changed

+95
-38
lines changed

2 files changed

+95
-38
lines changed

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/help/HelpActivity.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
import android.os.Bundle;
77
import android.view.Menu;
88
import android.view.MenuItem;
9+
import android.view.View;
10+
import android.view.ViewGroup;
11+
import android.widget.FrameLayout;
912

1013
import androidx.annotation.NonNull;
14+
import androidx.annotation.Nullable;
1115
import androidx.appcompat.app.AlertDialog;
1216
import androidx.lifecycle.ViewModelProvider;
1317
import androidx.preference.Preference;
1418
import androidx.preference.PreferenceFragmentCompat;
19+
import androidx.recyclerview.widget.RecyclerView;
1520

1621
import com.d4rk.androidtutorials.java.BuildConfig;
1722
import com.d4rk.androidtutorials.java.R;
@@ -38,7 +43,9 @@ protected void onCreate(Bundle savedInstanceState) {
3843
super.onCreate(savedInstanceState);
3944
ActivityHelpBinding binding = ActivityHelpBinding.inflate(getLayoutInflater());
4045
setContentView(binding.getRoot());
41-
EdgeToEdgeDelegate.apply(this, binding.getRoot());
46+
setSupportActionBar(binding.topAppBar);
47+
binding.topAppBar.setNavigationOnClickListener(v -> getOnBackPressedDispatcher().onBackPressed());
48+
EdgeToEdgeDelegate.apply(this, binding.helpContainer);
4249
AdUtils.loadBanner(binding.faqNativeAd);
4350
helpViewModel = new ViewModelProvider(this).get(HelpViewModel.class);
4451
new FastScrollerBuilder(binding.scrollContainer)
@@ -126,6 +133,29 @@ public static class FaqFragment extends PreferenceFragmentCompat {
126133
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
127134
setPreferencesFromResource(R.xml.preferences_faq, rootKey);
128135
}
136+
137+
@Override
138+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
139+
super.onViewCreated(view, savedInstanceState);
140+
RecyclerView listView = getListView();
141+
listView.setNestedScrollingEnabled(false);
142+
listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
143+
listView.setClipToPadding(false);
144+
145+
ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
146+
FrameLayout.LayoutParams frameLayoutParams;
147+
if (layoutParams instanceof FrameLayout.LayoutParams) {
148+
frameLayoutParams = (FrameLayout.LayoutParams) layoutParams;
149+
} else {
150+
frameLayoutParams = new FrameLayout.LayoutParams(
151+
ViewGroup.LayoutParams.MATCH_PARENT,
152+
ViewGroup.LayoutParams.WRAP_CONTENT
153+
);
154+
}
155+
frameLayoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
156+
frameLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
157+
listView.setLayoutParams(frameLayoutParams);
158+
}
129159
}
130160

131161
public static class FeedbackFragment extends PreferenceFragmentCompat {
Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,82 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<me.zhanghai.android.fastscroll.FastScrollScrollView
2+
<androidx.constraintlayout.widget.ConstraintLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:app="http://schemas.android.com/apk/res-auto"
5-
android:id="@+id/scroll_container"
5+
android:id="@+id/help_container"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent">
88

9-
<LinearLayout
10-
android:id="@+id/container"
11-
android:layout_width="match_parent"
9+
<com.google.android.material.appbar.MaterialToolbar
10+
android:id="@+id/top_app_bar"
11+
style="@style/Widget.Material3.Toolbar.Surface"
12+
android:layout_width="0dp"
1213
android:layout_height="wrap_content"
13-
android:orientation="vertical">
14+
app:layout_constraintEnd_toEndOf="parent"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintTop_toTopOf="parent"
17+
app:title="@string/help" />
1418

15-
<com.google.android.material.textview.MaterialTextView
16-
android:id="@+id/text_view_faq"
17-
android:layout_width="wrap_content"
18-
android:layout_height="wrap_content"
19-
android:layout_marginBottom="16dp"
20-
android:text="@string/faq"
21-
android:textAppearance="@style/TextAppearance.Material3.TitleMedium" />
19+
<me.zhanghai.android.fastscroll.FastScrollScrollView
20+
android:id="@+id/scroll_container"
21+
android:layout_width="0dp"
22+
android:layout_height="0dp"
23+
android:clipToPadding="false"
24+
app:layout_constraintBottom_toBottomOf="parent"
25+
app:layout_constraintEnd_toEndOf="parent"
26+
app:layout_constraintStart_toStartOf="parent"
27+
app:layout_constraintTop_toBottomOf="@id/top_app_bar">
2228

23-
<com.google.android.material.card.MaterialCardView
24-
android:id="@+id/card_view_faq"
25-
style="@style/Widget.Material3.CardView.Filled"
29+
<LinearLayout
30+
android:id="@+id/content_container"
2631
android:layout_width="match_parent"
2732
android:layout_height="wrap_content"
28-
app:shapeAppearance="@style/ShapeAppearanceOverlay.CardViewTopRoundedFilled">
33+
android:orientation="vertical"
34+
android:paddingHorizontal="24dp"
35+
android:paddingTop="24dp"
36+
android:paddingBottom="32dp">
37+
38+
<com.google.android.material.textview.MaterialTextView
39+
android:id="@+id/text_view_faq"
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:layout_marginBottom="12dp"
43+
android:text="@string/faq"
44+
android:textAppearance="@style/TextAppearance.Material3.TitleMedium" />
2945

30-
<LinearLayout
46+
<com.google.android.material.card.MaterialCardView
47+
android:id="@+id/card_view_faq"
48+
style="@style/Widget.Material3.CardView.Filled"
3149
android:layout_width="match_parent"
3250
android:layout_height="wrap_content"
33-
android:orientation="vertical"
34-
android:padding="12dp">
35-
<FrameLayout
36-
android:id="@+id/frame_layout_faq"
51+
android:layout_marginBottom="24dp"
52+
app:shapeAppearance="@style/ShapeAppearanceOverlay.CardViewTopRoundedFilled">
53+
54+
<LinearLayout
3755
android:layout_width="match_parent"
38-
android:layout_height="wrap_content" />
39-
</LinearLayout>
40-
</com.google.android.material.card.MaterialCardView>
56+
android:layout_height="wrap_content"
57+
android:orientation="vertical"
58+
android:padding="16dp">
4159

42-
<com.d4rk.androidtutorials.java.ads.views.NativeAdBannerView
43-
android:id="@+id/faq_native_ad"
44-
android:layout_width="match_parent"
45-
android:layout_height="wrap_content"
46-
android:layout_marginTop="2dp"
47-
app:nativeAdLayout="@layout/ad_help" />
60+
<FrameLayout
61+
android:id="@+id/frame_layout_faq"
62+
android:layout_width="match_parent"
63+
android:layout_height="wrap_content" />
64+
</LinearLayout>
65+
</com.google.android.material.card.MaterialCardView>
4866

49-
<FrameLayout
50-
android:id="@+id/frame_layout_feedback"
51-
android:layout_width="match_parent"
52-
android:layout_height="wrap_content" />
67+
<com.d4rk.androidtutorials.java.ads.views.NativeAdBannerView
68+
android:id="@+id/faq_native_ad"
69+
android:layout_width="match_parent"
70+
android:layout_height="wrap_content"
71+
android:layout_marginBottom="24dp"
72+
app:nativeAdLayout="@layout/ad_help" />
73+
74+
<FrameLayout
75+
android:id="@+id/frame_layout_feedback"
76+
android:layout_width="match_parent"
77+
android:layout_height="wrap_content" />
78+
79+
</LinearLayout>
80+
</me.zhanghai.android.fastscroll.FastScrollScrollView>
5381

54-
</LinearLayout>
55-
</me.zhanghai.android.fastscroll.FastScrollScrollView>
82+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)