[jp_post_view]
- 이 주제에는 2개 답변, 1명 참여가 있으며
mimoon가 3 년, 4 월 전에 전에 마지막으로 업데이트했습니다.
3 글 보임 - 1 에서 3 까지 (총 3 중에서)
-
글쓴이글
-
2021-04-20 3:09 오후 #14204
transition effects를 제외한 이상적인 설정
package com.mimoonchurch.powerbible; import androidx.appcompat.app.AlertDialog; import android.content.DialogInterface; import androidx.appcompat.app.AppCompatActivity; import androidx.core.view.KeyEventDispatcher; import android.app.Activity; import android.app.ProgressDialog; import android.view.KeyEvent; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.os.Bundle; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.LinearLayout; import android.widget.Toast; public class MainActivity extends AppCompatActivity { WebView web; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); web = new WebView(this); WebSettings webSettings = web.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setUseWideViewPort(true); web.getSettings().setLoadsImagesAutomatically(true); web.getSettings().setUseWideViewPort(true); web.getSettings().setLoadWithOverviewMode(true); webSettings.setBuiltInZoomControls(false); webSettings.setAllowUniversalAccessFromFileURLs(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setSupportMultipleWindows(true); webSettings.setSaveFormData(true); webSettings.setSavePassword(true); webSettings.setDomStorageEnabled(true); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(true); webSettings.setDatabaseEnabled(true); web.getSettings().setAppCacheEnabled(false); webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); web.setWebChromeClient(new WebChromeClient()); web.getSettings().setAppCacheEnabled(true); web.setWebViewClient(new WebViewClient()); web.loadUrl("https://mimoonchurch.net"); layout.addView(web); setContentView(layout); } private long backBtnTime = 0; @Override public void onBackPressed() { long curTime = System.currentTimeMillis(); long gapTime = curTime - backBtnTime; if (web.canGoBack()) { web.goBack(); } else if (0 <= gapTime && 2000 >= gapTime) { super.onBackPressed(); } else { backBtnTime = curTime; Toast.makeText(this, "한번 더 누르면 종료됩니다.", Toast.LENGTH_SHORT).show(); } } }
2021-04-20 3:42 오후 #14205이상적 소스 (그러나 느림)
activity_main.xml 내용<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".MainActivity"> <WebView android:id="@+id/wvLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:ignore="MissingConstraints" /> </androidx.constraintlayout.widget.ConstraintLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mimoonchurch.powerbible"> <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.Powerbible"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
strings.xml 내용에:
<resources> <string name="app_name">파워바이블</string> </resources>
themes.xml 내용에:
<resources xmlns:tools="http://schemas.android.com/tools"> <!-- Base application theme. --> <style name="Theme.Powerbible" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Primary brand color. --> <item name="colorPrimary">@color/purple_500</item> <item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorOnPrimary">@color/white</item> <!-- Secondary brand color. --> <item name="colorSecondary">@color/teal_200</item> <item name="colorSecondaryVariant">@color/teal_700</item> <item name="colorOnSecondary">@color/black</item> <!-- Status bar color. --> <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> <!-- Customize your theme here. --> </style> </resources>
MainActivity.java 내용에
package com.mimoonchurch.powerbible; import android.app.Activity; import android.app.ProgressDialog; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { ProgressDialog mProgressDialog; private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.setVisibility(View.GONE); mProgressDialog.setTitle("Loading"); mProgressDialog.show(); mProgressDialog.setMessage("Loading " + url); return false; } @Override public void onPageFinished(WebView view, String url) { mProgressDialog.dismiss(); animate(view); view.setVisibility(View.VISIBLE); super.onPageFinished(view, url); } } private void animate(final WebView view) { Animation anim = AnimationUtils.loadAnimation(getBaseContext(), android.R.anim.slide_in_left); view.startAnimation(anim); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { WebView view = (WebView) findViewById(R.id.wvLayout); if ((keyCode == KeyEvent.KEYCODE_BACK) && view.canGoBack()) { view.goBack(); return true; } return super.onKeyDown(keyCode, event); } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mProgressDialog = new ProgressDialog(this); WebView webView = (WebView) findViewById(R.id.wvLayout); webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl("https://mimoonchurch.net/"); webView.setWebViewClient(new HelloWebViewClient()); } }
2021-04-24 3:50 오전 #14246창 전환 효과 부분:
ProgressDialog mProgressDialog; private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.setVisibility(View.GONE); mProgressDialog.setTitle("Loading"); mProgressDialog.show(); mProgressDialog.setMessage("페이지를 불러옵니다"); return false; } @Override public void onPageFinished(WebView view, String url) { mProgressDialog.dismiss(); animate(view); view.setVisibility(View.VISIBLE); super.onPageFinished(view,url); } } private void animate(final WebView view) { Animation anim = AnimationUtils.loadAnimation(getBaseContext(), android.R.anim.slide_in_left); view.startAnimation(anim); }
-
글쓴이글
3 글 보임 - 1 에서 3 까지 (총 3 중에서)
- 답변은 로그인 후 가능합니다.