Android Kindle火webview背景显示黑色

时间:2014-04-29 13:24:35

标签: android webview kindle-fire

实际上我有一个问题点燃火webview显示背景黑色,我把它透明。在三星Galaxy s4或其他设备中看起来不错..只有我在kindleFire高清设备上遇到问题。

activity_display_help_option_screen.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rlDisplayHelpOption"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/img_bg_about_settings" >

    <RelativeLayout
        android:id="@+id/rlSplashBg"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <WebView
            android:id="@+id/webViewHelp"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginTop="5dp"
            android:background="@android:color/transparent" />
    </RelativeLayout>

</RelativeLayout>

HelpScreen.java

import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;



public class HelpScreen extends BaseActivity
{
    // Header Component
    private ImageView imgSliderOpen;
    private ImageView imgHelpIcon;
    private RelativeLayout rlDisplayHelpOption;

    // WebView.,
    private WebView webViewHelp;
    private TextView txtHelpHeader;
    private int Choice;
    private ImageView imgUATLogo;

    private ImageView imgBaboon;
    private final Animation fromTranslateAnimation = null;
    private final Animation endTtanslateAnimation = null;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_display_help_option_screen);
        this.initHeaderComponent();
        this.initViewControl();

        this.loadHtmlFileInWebView(1);
    }

    /**
     * Initialization view control. 
     */
    private void initViewControl()
    {

        this.rlDisplayHelpOption = (RelativeLayout) this.findViewById(R.id.rlDisplayHelpOption);

        this.txtHelpHeader = (TextView) this.findViewById(R.id.txtHelpHeader);
        this.txtHelpHeader.setTypeface(RiggedJumbleApplication.Fonts.JUNGLE_FEVER);

        this.imgUATLogo = (ImageView) this.findViewById(R.id.imgUATLogo);
        this.imgUATLogo.setVisibility(View.GONE);

        this.webViewHelp = (WebView) this.findViewById(R.id.webViewHelp);
        this.webViewHelp.getSettings().setJavaScriptEnabled(true);

        if (Build.VERSION.SDK_INT >= 11)
        {
            this.webViewHelp.setBackgroundColor(0x01000000);
            webViewHelp.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
        }
        else
        {
            this.webViewHelp.setBackgroundColor(0x00000000);
            // webViewHelp.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
        }
        // Only hide the scrollbar, not disables the scrolling:
        this.webViewHelp.setVerticalScrollBarEnabled(false);
        this.webViewHelp.setHorizontalScrollBarEnabled(false);

    }

    /**
     * Initialization header view control.
     */
    private void initHeaderComponent()
    {
        this.imgSliderOpen = (ImageView) this.findViewById(R.id.imgSliderOpen);
        this.imgSliderOpen.setVisibility(View.VISIBLE);
        this.imgSliderOpen.setImageResource(R.drawable.img_header_slider_back);
        this.imgSliderOpen.setOnClickListener(this.btnClickLister);
        this.imgHelpIcon = (ImageView) this.findViewById(R.id.imgHelp);
        this.imgHelpIcon.setVisibility(View.GONE);
        this.imgHelpIcon.setOnClickListener(this.btnClickLister);
    }

    /**
     * Button Click handler.
     */
    private final OnClickListener btnClickLister = new OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            switch (v.getId())
            {
            case R.id.imgSliderOpen:
                HelpScreen.this.isPlaySoundFile(HelpScreen.this, UatSoundMusicConstant.SOUND_CLICK);
                HelpScreen.this.finish();
                break;
            }
        }
    };

    /**
     * 
     */
    private void loadHtmlFileInWebView(int index)
    {
        switch (index)
        {
        case 1:
            this.imgUATLogo.setVisibility(View.GONE);
            this.txtHelpHeader.setText("TERMS");
            this.webViewHelp.loadUrl("file:///android_asset/HtmlFiles/doc_terms.html");
            break;
        default:
            break;
        }
    }
}

Samsung S4 Image in which webview showing perfect

Kindle Fire webview background showing black

  1. Samsung S4 Webview Working Proper

  2. Kindle Fire Webview背景显示文本问题背后的黑色位置。

0 个答案:

没有答案