android自动调整webview而不重新加载它

时间:2012-07-05 12:30:11

标签: java android eclipse

我有一个带webview和admob的布局。我还为了处理onConfigChanges而在主要活动中设置了方向键盘,以便在设备旋转时不重新加载页面内容。 当appstarts创建webview并加载内容时,admob会出现,但webview不会自动调整大小!当发生这种情况时,我将设备转为横向并返回到纵向,布局调整大小并正确安装! 我怎么能强制webview再次自动调整大小?我尝试了几个选项,但没有成功!谢谢

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">


      <com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="xxx"
                         ads:adSize="SMART_BANNER"
                         ads:testDevices="TEST_EMULATOR, xxx"
                         ads:loadAdOnCreate="true"/>    

<RelativeLayout
                    android:id="@+id/bLayout"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_below="@+id/barraSocial">

                    <WebView
                        android:id="@+id/webviewB"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:autoLink="web"
                        android:textColor="@android:color/black" 
                        android:scrollbars="none"
                        />
                </RelativeLayout>

2 个答案:

答案 0 :(得分:0)

尝试强制您的广告的高度。像这样的东西

<com.google.ads.AdView android:id="@+id/adView"
                     android:layout_width="wrap_content"
                     android:layout_height="@dimen/adview_height" />

adview height是存储在res / values / dimen.xml中的值,例如:

<resources>
    <dimen name="adview_height">30dp</dimen>
</resources>

答案 1 :(得分:0)

默认情况下尝试将视图设置为隐藏:

Sub keep_specific_columns()
    Dim currentColumn As Integer
    Dim columnHeading As String

    For currentColumn = Worksheets("Incidents_data").UsedRange.Columns.Count To 1 Step -1

        columnHeading = Worksheets("Incidents_data").UsedRange.Cells(1, currentColumn).Value

        'CHECK WHETHER TO KEEP THE COLUMN
        Select Case columnHeading
            Case "nameA", "nameB", "nameC"
                'Do nothing
            Case Else
                'Delete if the cell doesn't contain "x"
                If InStr(1, _
                    Worksheets("Incidents_data").UsedRange.Cells(1, currentColumn).Value, _
                   "DLP", vbBinaryCompare) = 0 Then

                     Worksheets("Incidents_data").Columns(currentColumn).Delete

                End If
        End Select
    Next

End Sub

并在加载内容时将其设置为可见:

android:visibility="gone"