我有一个Dialog类,在其中实例化以显示webview。正如您在下面的代码中看到的那样,它不是全屏。我尝试了很多更改,但在最好的情况下,它仍然没有处于全屏模式。怎么办?
public class MyDialog extends Dialog {
static final float[] DIMENSIONS_LANDSCAPE = { 460, 260 };
static final float[] DIMENSIONS_PORTRAIT = { 280, 420 };
static final FrameLayout.LayoutParams FILL = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
static final int MARGIN = 4;
static final int PADDING = 2;
private String mUrl;
private OAuthDialogListener mListener;
private ProgressDialog mSpinner;
private WebView mWebView;
private LinearLayout mContent;
private TextView mTitle;
private static final String TAG = "My-WebView";
public MyDialog(Context context, String url,
OAuthDialogListener listener) {
super(context);
mUrl = url;
mListener = listener;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSpinner = new ProgressDialog(getContext());
mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
mSpinner.setMessage("Loading...");
mContent = new LinearLayout(getContext());
mContent.setOrientation(LinearLayout.VERTICAL);
setUpTitle();
setUpWebView();
Display display = getWindow().getWindowManager().getDefaultDisplay();
final float scale = getContext().getResources().getDisplayMetrics().density;
float[] dimensions = (display.getWidth() < display.getHeight()) ? DIMENSIONS_PORTRAIT
: DIMENSIONS_LANDSCAPE;
addContentView(mContent, new FrameLayout.LayoutParams(
(int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1]
* scale + 0.5f)));
CookieSyncManager.createInstance(getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
}
private void setUpTitle() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
mTitle = new TextView(getContext());
mTitle.setText("My Site");
mTitle.setTextColor(Color.WHITE);
mTitle.setTypeface(Typeface.DEFAULT_BOLD);
mTitle.setBackgroundColor(Color.BLACK);
mTitle.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN);
mContent.addView(mTitle);
}
private void setUpWebView() {
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new OAuthWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
}
private class OAuthWebViewClient extends WebViewClient {
//some code
}
public interface OAuthDialogListener {
public abstract void onComplete(String accessToken);
public abstract void onError(String error);
}
}
我已经更改了以下代码,它使对话框更大但仍然不是全屏:
addContentView(mContent, new FrameLayout.LayoutParams(
display.getWidth() , display.getHeight()));
MyDialog被实例化并在另一个类中启动,如下所示:
class A {
//some code
MyDialog mDialog = new MyDialog(context, mAuthUrl, listener);
mDialog.show();
}
答案 0 :(得分:1)
试试这个:
public function view($id){
// retrieve ServiceRequest data
$serviceRequest = $this->ServiceRequest->findById($id);
// retrieve Client data
$options['joins'] = array(
array('table' => 'client_services',
'alias' => 'ClientService',
'type' => 'INNER',
'conditions' => array(
'Client.id = ClientService.client_id',
)
),
array('table' => 'client_service_areas',
'alias' => 'ClientServiceArea',
'type' => 'INNER',
'conditions' => array(
'Client.id = ClientServiceArea.client_id',
)
),
);
$options['conditions'] = array(
'ClientService.service_id'=>$serviceRequest['ServiceRequest']['service_id'],
'ClientServiceArea.service_area_id'=>$serviceRequest['ServiceRequest']['service_area_id']
);
$options['group'] = array('Client.id');
$Client = ClassRegistry::init('Client');
$clients = $Client->find('all', $options);
$this->set(compact('serviceRequest','clients'));
}
答案 1 :(得分:0)
尝试使用dialogFragment。在其中使用以下代码
4.076530 4.179765 4.213305 4.028456 4.407819 4.282502 4.494677 4.484104 4.413574 3.967853
并将values / styles.xml中的样式声明为
public class myDialog extends DialogFragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, R.style.NewDialog);
}
希望这有帮助!
答案 2 :(得分:0)
试试这个,
Java类
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = width;
lp.height = height;
dialog.getWindow().setAttributes(lp);
<强> Style.xml 强>
<style name="DialogTheme" parent="android:Theme.Dialog">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<!-- No backgrounds, titles or window float -->
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
</style>