Skip to content

Commit 3e4633d

Browse files
committed
Mises à jour
1 parent 808c935 commit 3e4633d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

app/src/main/java/com/hugdev/webapper/MainActivity.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected void onCreate(Bundle savedInstanceState) {
9191
Button bottomButton = findViewById(R.id.bottomButton);
9292
Button leftButton = findViewById(R.id.leftButton);
9393
Button rightButton = findViewById(R.id.rightButton);
94-
HorizontalScrollView scroll = findViewById(R.id.scroll);
94+
LinearLayout linearLayout2 = findViewById(R.id.scrollvv);
9595
scroll.fullScroll(View.FOCUS_DOWN);
9696
WebView webView = findViewById(R.id.webview);
9797
webView.getSettings().setJavaScriptEnabled(true);
@@ -108,30 +108,35 @@ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request
108108
topButton.setOnClickListener(new View.OnClickListener() {
109109
@Override
110110
public void onClick(View v) {
111-
scroll.scrollTo(0, 0); // Scroll to left
111+
// Scroll to the top
112+
scroll.fullScroll(View.FOCUS_UP);
112113
}
113114
});
114115

115116
bottomButton.setOnClickListener(new View.OnClickListener() {
116117
@Override
117118
public void onClick(View v) {
118-
scroll.scrollTo(0, scroll.getChildAt(0).getHeight()); // Scroll to right
119+
// Scroll to the bottom
120+
scroll.fullScroll(View.FOCUS_DOWN);
119121
}
120122
});
121123

122124
leftButton.setOnClickListener(new View.OnClickListener() {
123125
@Override
124126
public void onClick(View v) {
125-
scroll.scrollTo(0, 0); // Scroll to top
127+
// Scroll to the left
128+
scroll.fullScroll(View.FOCUS_LEFT);
126129
}
127130
});
128131

129132
rightButton.setOnClickListener(new View.OnClickListener() {
130133
@Override
131134
public void onClick(View v) {
132-
scroll.scrollTo(scroll.getChildAt(0).getWidth(), 0); // Scroll to bottom
135+
// Scroll to the right
136+
scroll.fullScroll(View.FOCUS_RIGHT);
133137
}
134138
});
139+
135140
Button soundButton = findViewById(R.id.soundButton);
136141
soundButton.setOnClickListener(v -> {
137142
// Créer une boîte de dialogue avec trois options

app/src/main/res/layout/activity_main.xml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
tools:context=".MainActivity">
99

1010
<LinearLayout
11+
android:id="@+id/scrollvv"
1112
android:layout_width="match_parent"
1213
android:layout_height="match_parent"
1314
android:fitsSystemWindows="true"

0 commit comments

Comments
 (0)