2014-04-18 1 views
-3

웹보기에서 단추와 편집 문구를 만들려고합니다. 둘 다 페이지 뒤쪽에 있어야합니다. 아래에 게시 된 내 attemps에서 나는 webview에서 버튼과 edittext 영역을 모두 설정할 수 있었지만 문제는 단추와 edittext 영역 모두가 섀도 잉되거나 웹 페이지의 내용으로 덮여 있다는 것입니다. 해당 요소와 내용을 혼합하지 않도록하는 방법이 있습니까?내용을 혼합하지 않고 웹보기에서 단추를 표시하는 방법

JavaCode :

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.activity_web_page00); 

    webView00 = (WebView) findViewById(R.id.webView00); 
    btnGo = (Button) findViewById(R.id.go_btn); 
    etUrl = (EditText) findViewById(R.id.url_edittext); 

    webView00.getSettings().setJavaScriptEnabled(true); 
    webView00.setWebViewClient(new myWebViewClient()); 
    webView00.setWebChromeClient(new myWebChromeClient()); 

    webView00.loadUrl("http://google.com"); 

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" 
    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="com.example.webapptest01.WebAppTest01$PlaceholderFragment" > 

    <WebView 
     android:id="@+id/webView00" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 

    <Button 
     android:id="@+id/go_btn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:text="Go!" /> 

    <EditText 
     android:id="@+id/url_edittext" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:minWidth="220dp" /> 

</RelativeLayout> 
+0

는'사용 FrameLayout'을 추가 한'LinearLayout'을이'LinearLayout'에 버튼을 추가하고이'Linearlayout' –

+0

에 아래로 중력을 설정할 수 있습니다 XML 코드 relativeLayout 대신 FrameLayout을 사용해야합니까? – EDECoder

답변

0

단일 RelativeLayout (NO 중첩 된 레이아웃)로 유지하고 android:layout_above 속성을 사용하게 한 가지 방법 :

<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="com.example.webapptest01.WebAppTest01$PlaceholderFragment" > 

    <Button 
     android:id="@+id/go_btn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:text="Go!" /> 

    <EditText 
     android:id="@+id/url_edittext" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:minWidth="220dp" /> 

    <WebView 
     android:id="@+id/webView00" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/url_edittext" /> 

</RelativeLayout> 
+0

덕분에 지금은 효과가 있었지만 다음과 같은 질문에 답해주세요. 1) 어떻게 동일한 결과를 얻을 수 있습니까?하지만 먼저 FrameLayout과 LinearLayout을 사용하면 어떻게됩니까? 2) 왜 내 질문에 등급이 매겨지고 있습니까? – EDECoder

+0

FrameLayout과 LinearLayout을 사용하지 않을 것을 제안했는데 다른 사람이 그랬습니다. 나는 (물론 :)) 내 솔루션이 더 좋다고 생각합니다. 단지 1 개의 부모 레이아웃 만 사용합니다. 왜 당신은 downvoted되고 있습니까? 나도 몰라, 너를 다운시키지 않았다. 코드 형식이 완벽하지 않았기 때문에 (또는 훨씬 더 나 빠졌지 만) 사람이 간단한 질문이라고 생각하고 충분히 열심히 시도하지 않았습니다 (나는 훨씬 더 나쁜 질문을 보았습니다). StackOverflow의 사람들은 변덕 스러울 수 있습니다. 너무 걱정하지 마십시오. –

0

상대 레이아웃 대신 프레임 레이아웃을 사용해야합니다. 여기

는이

<FrameLayout 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" > 

    <WebView 
     android:id="@+id/webView00" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/url_edittext" /> 

    <Button 
     android:id="@+id/go_btn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right|bottom" 
     android:text="Go!" /> 

    <EditText 
     android:id="@+id/url_edittext" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:minWidth="220dp" /> 

</FrameLayout> 
관련 문제