2015-10-15 80 views
-1

我有一個scrollview中的webviews的列表視圖。最初的列表視圖顯示5行的高度合適,直到webview內容沒有加載。一旦內容加載到webview中(通過網絡調用),現在我只能看到3行增加了高度,不知道天氣如何增加listview高度或滾動視圖高度是否增加。
這裏是XML代碼,如何使用webview動態設置高度到listview

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
    android:scrollbars="vertical"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 


     <RelativeLayout 
      android:id="@+id/relativeLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center_vertical"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignBottom="@+id/relativeLayout" 
       android:layout_alignParentTop="true" 
       android:scaleType="centerCrop" 
       android:src="@drawable/bg_img_welcome" /> 

      <ImageView 
       android:id="@+id/imageView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:paddingLeft="25dp" 
       android:paddingRight="25dp" 
       android:paddingTop="5dp" 

       android:src="@drawable/rashays_rewards_logo" /> 

      <ImageView 
       android:id="@+id/welcome" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/imageView" 
       android:layout_centerHorizontal="true" 
       android:paddingLeft="25dp" 
       android:paddingRight="25dp" 

       android:src="@drawable/welcome" /> 

      <RelativeLayout 
       android:id="@+id/relativeLayout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/welcome" 
       android:gravity="center_horizontal" 
       android:paddingBottom="10dp"> 

       <insessor.typeface.TextViewGothic 
        android:id="@+id/customer_name" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:text="CUSTOMER NAME" 
        android:textColor="@color/white" 
        android:textSize="15dp" /> 

       <com.github.siyamed.shapeimageview.RoundedImageView 
        android:id="@+id/customer_profile_picture" 
        android:layout_width="100dp" 
        android:layout_height="100dp" 
        android:layout_below="@+id/customer_name" 
        android:layout_centerHorizontal="true" 
        android:layout_marginTop="10dp" 
        android:src="@drawable/user_placeholder" 
        app:siBorderColor="@color/white" 
        app:siBorderWidth="3dp" 
        app:siRadius="6dp" 

        app:siSquare="true" /> 
      </RelativeLayout> 
     </RelativeLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/relativeLayout1" 
      android:background="@color/bg_drack_gray" 
      android:gravity="center" 
      android:orientation="vertical" 
      android:padding="5dp"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@color/bg_drack_gray" 
       android:gravity="center" 
       android:orientation="horizontal"> 

       <insessor.typeface.TextViewchunk 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="top|center" 
        android:padding="2dp" 
        android:text="$" 
        android:textColor="@color/white" 
        android:textSize="30dp" /> 

       <insessor.typeface.TextViewchunk 
        android:id="@+id/reward_points" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:text="222" 
        android:textColor="@color/white" 
        android:textSize="50dp" /> 
      </LinearLayout> 

      <insessor.typeface.TextViewGothic 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="Rashay’s Reward Points" 
       android:textColor="@color/rashays_orenge" 
       android:textSize="15dp" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout1" 
      android:layout_gravity="center" 
      android:background="@color/white" 
      android:gravity="center" 
      android:orientation="horizontal" 
      android:paddingTop="2dp" 
      android:weightSum="4"> 

      <ImageView 
       android:id="@+id/redeem_dollar" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/redeem_dollar" /> 

      <ImageView 
       android:id="@+id/contactus" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/contactus" /> 

      <ImageView 
       android:id="@+id/menu" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/menu" /> 

      <ImageView 
       android:id="@+id/booking" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/booking" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout2" 
      android:background="@color/white" 
      android:gravity="center" 
      android:orientation="vertical"> 

      <insessor.typeface.TextViewGothicBold 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:letterSpacing=".2" 
       android:text="NEWSFEED" 
       android:textSize="18sp" /> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="1px" 
       android:layout_gravity="center" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_marginTop="5dp" 
       android:background="@color/separator" /> 
     </LinearLayout> 


     <RelativeLayout 
      android:id="@+id/RelativeLayout3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout3" 
      android:orientation="vertical"> 

      <ListView 
       android:id="@+id/newsfeed_list" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

      </ListView> 
     </RelativeLayout> 

     <include 
      layout="@layout/footer_text" 
      android:layout_width="match_parent" 
      android:layout_height="28dp" 
      android:layout_below="@+id/RelativeLayout3" 
      /> 


    </RelativeLayout> 

</ScrollView> 

我認爲的WebView加載內容已晚。 更新了代碼。添加圖片,網頁視圖內容加載之前

擷取畫面,視圖內容加載後

enter image description here

擷取畫面,

enter image description here

+0

'我有一個scrollview查看webview的列表視圖.'所以你有一個可滾動的滾動滾動滾動...多麼可怕的設計。甚至沒有提到無用的佈局嵌套。 –

+1

我同意弗蘭克你有3個可滾動。我建議只列出一個列表視圖,其中的內容會打開一個新的片段或活動,並在您擁有網頁視圖的活動中顯示。要記住在活動中有多個Web視圖實例會輕易殺死你的應用程序。 – PedroAGSantos

+0

還有其他幾種佈局。感謝您的通知。讓我更新這個問題。 –

回答

0

我想了很多,終於解決了這個問題,我刪除了滾動視圖並將scrollview的內容添加到listview的頁眉和頁腳中。

感謝所有支持,我認爲它不是一個好的方式來使用滾動視圖與列表視圖。