2013-11-24 7 views
13

एंड्रॉइड एप्लिकेशन पूर्ण स्क्रीन का वेबव्यू कैसे बनाएं। मैंने लेआउट xml फ़ाइल पर वेबव्यू जोड़ा है लेकिन यह लेआउट के किनारों तक फैला नहीं है, वेबव्यू के सभी किनारे पर कुछ प्रकार का मार्जिन है। मैं आपको लोगों को एक संकेत देने के लिए एक छवि भी जोड़ रहा हूं कि वास्तव में यह कैसा दिख रहा है।एक पूर्ण स्क्रीन वेबव्यू कैसे बनाएं

What i am talking about is the space all around the webview, not the notification bar or the title bar

क्या मैं बात कर रहा हूँ सब वेबव्यू चारों ओर अंतरिक्ष, नहीं सूचना पट्टी या शीर्षक पट्टी

यहाँ है लेआउट कोड है:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".WebView" > 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:text="Shake/Tilt Your Phone To Get Accelerometer Motion Alerts" /> 

<WebView 
    android:id="@+id/webview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" /> 

</RelativeLayout> 
+0

आप पोस्ट कर सकते हैं उर लेआउट xm एल कोड कृपया? –

+0

@JohnJared ने अभी – Arihant

उत्तर

17

कोड ऊपर से हटाने padding tags -

android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 

यह काम करते हैं और यह भी एचटीएमएल के मार्जिन/गद्दी जो आप WebView कि उन टैग जो कुछ जगह छोड़ देता है शामिल हो सकता है में प्रदान कर रहे हैं को दूर करने के लिए सुनिश्चित हो जाएगा।

+0

से ऊपर कोड जोड़ा है, मैंने अभी प्रश्न में एक्सएमएल कोड जोड़ा है। कृपया इसे – Arihant

+0

पर एक नज़र दें, यहां तक ​​कि पैडिंग मान शून्य थे, फिर भी यह कुछ जगह दिखा रहा था, क्या आप कारण बता सकते हैं? मैंने पैडिंग और फिक्स्ड हटा दिया। – MAK

7

बस जोड़ने (या बदलें) गतिविधि की android:theme AndroidManifest.xml फ़ाइल में निम्न पंक्ति के साथ विशेषता

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
0

आप res/values ​​फ़ोल्डर में dimens.xml में आयाम सेट कर सकते हैं। डिफ़ॉल्ट रूप से यह 16 डीपी है। तो इसे तदनुसार सेट कर सकते हैं।

enter image description here

3

एंड्रॉयड संस्करण: 4.2.2 - डिवाइस: वेगा गोली

WebView स्थिति और सिस्टम बार और पूर्ण स्क्रीन मैं इन चरणों का पालन प्रदर्शित छिपाने के लिए।

AndroidManifest.xml

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name"> 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

MainActivity.java

super.onCreate(savedInstanceState); 
getWindow().getDecorView().setSystemUiVisibility(0x10); 
setContentView(R.layout.activity_main); 
String url = "http://edition.cnn.com/"; 
WebView webView = (WebView) findViewById(R.id.webView); 
webView.getSettings().setJavaScriptEnabled(true); 
webView.getSettings().setUserAgentString("Desktop"); 
webView.loadUrl(url); 

उपरोक्त प्रक्रिया मेरे लिए काम किया है और मेरे ऐप पूरा स्क्रीन में प्रदर्शित किया जाता है।

0

आपको सापेक्ष लेआउट सेटिंग्स बदलनी चाहिए। और XML फ़ाइल पर वेबव्यू पर कोई भी पैडिंग सेटिंग्स को हटा दें।

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    tools:context=".MainActivity" 
 
    android:id="@+id/frame">

0

संवाद पॉप अप विंडो में रखें वेबव्यू।

WebView webview = new WebView(this/*put your activity object*/); 
    webview.getSettings().setLoadWithOverviewMode(true); 
    webview.getSettings().setUseWideViewPort(false); 
    webview.getSettings().setSupportZoom(false); 
    webview.getSettings().setJavaScriptEnabled(true); 
    webview.setBackgroundColor(Color.TRANSPARENT); 
    webview.loadUrl("http://www.awwwards.com/websites/responsive-design/"); 

    RelativeLayout.LayoutParams paramsWebView = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); 
    Dialog dialog = new Dialog(this/*put your activity object*/, android.R.style.Theme_Black_NoTitleBar_Fullscreen); 
    dialog.addContentView(webview, paramsWebView); 
    dialog.show(); 
0

डॉक्स से https://developer.android.com/guide/webapps/webview.html

<?xml version="1.0" encoding="utf-8"?> 
<WebView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/webview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
/> 

FILL_PARENT, जिसका अर्थ है कि दृश्य अपनी मूल (ऋण गद्दी) के रूप में के रूप में बड़ी

बनना चाहता है (एपीआई स्तर 8 और उच्च में नाम बदलकर MATCH_PARENT)

https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html

संबंधित मुद्दे