2013-01-06 48 views
0

我再次花了几个小时来解决这个(简单),但对我来说很难的问题。我不能把按钮放在视图中。xml把按钮放下

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

      <ImageView 
       android:id="@+id/imageView1" 

       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       /> 

      <ScrollView 
       android:id="@+id/scrollView1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <WebView 
        android:id="@+id/webView1" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" /> 
      </ScrollView> 
</LinearLayout> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<Button 
    android:id="@+id/button1" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    android:text="Button" /> 

</LinearLayout> 
</LinearLayout> 
+1

你不需要来包装你的WebView在一个滚动型。如果需要,WebView将自行滚动。 – dymmeh

回答

0

你不能这样做,在LinearLayout。相反,尝试RelativeLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 

     <ImageView 
      android:id="@+id/imageView1" 

      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      /> 

     <ScrollView 
      android:id="@+id/scrollView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <WebView 
       android:id="@+id/webView1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
     </ScrollView> 
    </LinearLayout> 

<Button 
    android:id="@+id/button1" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:text="Button" /> 

</LinearLayout> 

+0

按钮有可能被这种方式覆盖。移动XML中LinearLayout上方的按钮...然后将线性布局设置为具有标签android:layout_above =“@ + id/button1” – dymmeh

+0

谢谢,运行!只有一件事:为什么我在webview上看不到文字?如果在没有这段代码的情况下放置webview,我会在webview上看到文本(java代码可以)。 –

+0

这就是我认为的问题所在。在这里阅读答案(不知道虽然)http://stackoverflow.com/questions/12567472/scroll-webview-inside-a-scroll-view – cjds