2014-02-07 2 views
0

У меня есть представление TextViews и WebView, которые я хочу скопировать как единицу, вместо прокрутки WebView, когда это необходимо из-за длины содержимого. Это, наверное, что-то простое, но, похоже, я не могу заставить его работать, так как у WebView есть полоса прокрутки.Использование ScrollView вместо прокрутки в WebView

Это мой макет файла:

<ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/imageView" 
     android:src="@drawable/background_tablet" 
     android:scaleType="centerCrop" 
    android:contentDescription="@string/background_image" /> 

<LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/list_background_overlay"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="10dp" 
     android:background="@color/list_background_overlay" 
     android:baselineAligned="false"> 

    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:text="@string/author" 
      android:id="@+id/article_view_author" 
      /> 

    <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="@string/title" 
      android:id="@+id/article_titleView" android:layout_gravity="center_horizontal" 
      android:gravity="center_horizontal"/> 

    <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      > 

     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="@string/site" 
       android:id="@+id/article_view_site"/> 

     <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="@string/date_unknown" 
       android:id="@+id/article_view_date" 
       android:gravity="right"/> 
    </LinearLayout> 
</LinearLayout> 

    <RelativeLayout 
      android:orientation="horizontal" 
      android:layout_width="fill_parent" 
      android:layout_height="70dp" 
      android:background="@color/list_background_overlay" 
      android:id="@+id/article_mediaLayout" 
      android:padding="10dp" 
      > 

     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="@string/duration_default" 
       android:id="@+id/article_duration" 
       android:gravity="left" 
       android:layout_alignParentLeft="true" 
       android:layout_centerVertical="true" 
       /> 

     <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/play" 
       android:id="@+id/article_playBttn" 
       android:layout_alignTop="@+id/article_preview" 
       android:layout_centerInParent="true"/> 

     <ImageView 
       android:layout_width="100dp" 
       android:layout_height="50dp" 
       android:id="@+id/article_preview" 
       android:layout_gravity="center" 
       android:layout_centerVertical="true" 
       android:layout_alignParentRight="true" 
       android:paddingRight="20dp" 
      android:contentDescription="@string/preview_image" /> 

     <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="512dp" 
       android:layout_alignParentTop="true" 
       android:layout_marginTop="10dp" 
       android:id="@+id/relativeLayout"> 
     </RelativeLayout> 
    </RelativeLayout> 

    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="15dp" 
     android:id="@+id/article_filler"> 
</FrameLayout> 

<FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/list_background_overlay" 
     android:paddingTop="20dp" 
     android:paddingBottom="20dp"> 

    <WebView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/article_contentView" android:layout_gravity="center_horizontal" 
      android:padding="10dp" 
      android:paddingTop="30dp" 
      android:paddingBottom="20dp"/> 
</FrameLayout> 

ответ

0

Webview ч как внутренний скроллер. Из-за этого неплохо было бы обернуть его в другой scrollview. Я не знаю, насколько сложна ваша HTML-версия или есть ли она в вашем случае в любом случае, но, возможно, вам стоит подумать, чтобы показать ее в чисто текстовом виде, как описано здесь: How to display HTML in TextView?

+1

Это в основном HTML-форма RSS-каналов, поэтому может включать все от изображений до css. TextView не подходит, я думаю, немного поиграл. Есть ли способ узнать высоту WebView, поэтому я могу обновить высоту кадра WebView –

Смежные вопросы