在GoogleTV中将分辨率设置为720p或1080p?

时间:2013-05-15 16:15:27

标签: android google-tv

如何限制我的GoogleTV应用以特定分辨率显示:即720P,1080p等?出于某种原因,即使我的GoogleTV和显示器可以处理1080p,我的应用程序仍然坚持以960x540左右的分辨率显示。

我不确定它只是我的GoogleTV仅在960x540上显示,或者其他GoogleTV也看到同样的事情。无论如何,我想确保我的应用只能以分辨率查看:960x540或1280x720

2 个答案:

答案 0 :(得分:1)

Google TV上的每个显示都不同。 (除了LG之类的内置电视外)当你打开Goog​​le TV时,有一个步骤可以确定电视的分辨率。

目前大多数Google TV(基于ARM)都是1080p。缩小到720是由您的电视完成的。

所有这一切,960x540是720p或1080p的Android设备像素。

所以,总而言之,你不能/不应该做你的要求。

答案 1 :(得分:0)

我明白了。我必须设置webview的初始比例,这使我能够在720p中查看WebView,即使屏幕分辨率为1080p。

这是我使用的代码:

boolean _bReloaded = false;
boolean _bLoaded = false;
int _nWebScale = 100;
DisplayMetrics displaymetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int nScreenHeight = displaymetrics.heightPixels;  
if(nScreenHeight >= 1000){
    _nWebScale = (int) Math.round((nScreenHeight/720.0) * 100.0); 
    _bReloaded = false;
    mWebView.setVisibility(View.INVISIBLE);
}
mWebView.setInitialScale(_nWebScale);

但我没有在那里完成。

此时,webView以适当的分辨率显示;但是,当webView加载时,webview窗口会有明显的大小调整。这就是为什么在上面的代码中我隐藏了webview。另一个问题是,在我的特定情况下,我的HTML没有收听窗口调整大小事件,因此在webview明显改变大小后它没有重新调整其UI。为了解决这个问题,我可以更改我的HTML并让它对JavaScript窗口调整大小事件作出反应,或者我可以做我最终使用的内容 - 在加载不正确大小的UI后重新加载webview。使用此解决方案,我不必对窗口大小调整事件做出反应:

mWebView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            if (progress == 100) {
                if(_nWebScale != 100 && (mWebView.getVisibility() != View.VISIBLE) && !_bReloaded){
                    _bReloaded = true;
                    mWebView.reload();
                } else {
                    _bLoaded = true;
                    displayLoadingSpinner(false);
                    mWebView.setVisibility(View.VISIBLE);
                }
            } else if (mProgressBar.getVisibility() != View.VISIBLE) {
                displayLoadingSpinner(true);
                _bLoaded = false;
            }
        }
});

与原始问题没有直接关系但可能有用的另一条信息如下。在我的代码中,我不得不根据从webview发送的参数调整VideoView的大小并重新定位。但由于webview的分辨率可能与实际显示分辨率不同,因此我必须根据屏幕分辨率调整参数。

例如:

//this parameter is equal to the width of the webview screen: 720
nHeightFromWebView;
//This is the x position of where the VideoView should be placed.
nXFromWebView; 

float nScale = (float)_nWebScale/100;
int nAdjustedHeight = (int) Math.round(((float)nHeightFromWebView * nScale)); 
//The adjusted height computes to 1080 - the actual resolution of the screen
int nNewX = (int)Math.round((float)nXFromWebView * nScale);