android.view.Window.setContentView()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中android.view.Window.setContentView()方法的一些代码示例,展示了Window.setContentView()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.setContentView()方法的具体详情如下:
包路径:android.view.Window
类名称:Window
方法名:setContentView

Window.setContentView介绍

暂无

代码示例

代码示例来源:origin: gzu-liyujiang/AndroidPicker

private void initDialog() {
  contentLayout = new FrameLayout(activity);
  contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
  contentLayout.setFocusable(true);
  contentLayout.setFocusableInTouchMode(true);
  dialog = new Dialog(activity);
  dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
  dialog.setCancelable(true);//按返回键取消窗体
  dialog.setOnKeyListener(this);
  dialog.setOnDismissListener(this);
  Window window = dialog.getWindow();
  if (window != null) {
    window.setGravity(Gravity.BOTTOM);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    //AndroidRuntimeException: requestFeature() must be called before adding content
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setContentView(contentLayout);
  }
  setSize(screenWidthPixels, WRAP_CONTENT);
}

代码示例来源:origin: aa112901/remusic

alertDialog.show();
Window window = alertDialog.getWindow();
window.setContentView(R.layout.dialog);
final EditText editText = (EditText) (window.findViewById(R.id.message));
editText.requestFocus();

代码示例来源:origin: aa112901/remusic

alertDialog.show();
Window window = alertDialog.getWindow();
window.setContentView(R.layout.dialog);
final EditText editText = (EditText) (window.findViewById(R.id.message));
editText.requestFocus();

代码示例来源:origin: stackoverflow.com

Window window = getWindow();
 window.setContentView(v);`

代码示例来源:origin: AnJiaoDe/BaseDialog

public BaseDialog contentView(@NonNull View view, @Nullable ViewGroup.LayoutParams params) {
  getWindow().setContentView(view, params);
  return this;
}
public BaseDialog layoutParams(@Nullable ViewGroup.LayoutParams params) {

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

@Override
public void setContentView(int layoutResId) {
  if (ActionBarSherlock.DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId);
  mActivity.getWindow().setContentView(layoutResId);
  initActionBar();
}

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

@Override
public void setContentView(View view, LayoutParams params) {
  if (ActionBarSherlock.DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params);
  mActivity.getWindow().setContentView(view, params);
  initActionBar();
}

代码示例来源:origin: com.willowtreeapps/oak-demos

@Override
public void setContentView(int layoutResId) {
  if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId);
  mActivity.getWindow().setContentView(layoutResId);
  initActionBar();
}

代码示例来源:origin: com.willowtreeapps/oak-demos

@Override
public void setContentView(View view, LayoutParams params) {
  if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params);
  mActivity.getWindow().setContentView(view, params);
  initActionBar();
}

代码示例来源:origin: AnJiaoDe/BaseDialog

public BaseDialog contentView(@LayoutRes int layoutResID) {
  getWindow().setContentView(layoutResID);
  return this;
}

代码示例来源:origin: AnJiaoDe/BaseDialog

public BaseDialog contentView(@NonNull View view) {
  getWindow().setContentView(view);
  return this;
}

代码示例来源:origin: trishika/DroidUPnP

@Override
public void setContentView(int layoutResID)
{
  ViewGroup contentView = (ViewGroup) LayoutInflater.from(this).inflate(
      R.layout.preference_activity, new LinearLayout(this), false);
  mActionBar = (Toolbar) contentView.findViewById(R.id.action_bar);
  mActionBar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      finish();
    }
  });
  ViewGroup contentWrapper = (ViewGroup) contentView.findViewById(R.id.content_wrapper);
  LayoutInflater.from(this).inflate(layoutResID, contentWrapper, true);
  getWindow().setContentView(contentView);
}

代码示例来源:origin: com.googlecode.playn/playn-android

protected void setContentView(GameViewGL view) {
  LinearLayout layout = new LinearLayout(this);
  layout.setBackgroundColor(0xFF000000);
  layout.setGravity(Gravity.CENTER);
  layout.addView(gameView);
  LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  getWindow().setContentView(layout, params);
 }
}

代码示例来源:origin: threerings/playn

protected void setContentView(GameViewGL view) {
  LinearLayout layout = new LinearLayout(this);
  layout.setBackgroundColor(0xFF000000);
  layout.setGravity(Gravity.CENTER);
  layout.addView(gameView);
  LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  getWindow().setContentView(layout, params);
 }
}

代码示例来源:origin: playn/playn

protected void setContentView(GameViewGL view) {
  LinearLayout layout = new LinearLayout(this);
  layout.setBackgroundColor(0xFF000000);
  layout.setGravity(Gravity.CENTER);
  layout.addView(gameView);
  LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  getWindow().setContentView(layout, params);
 }
}

代码示例来源:origin: alexeykovalev/epg_magic_carousel

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar);
  // hides Android notification bar
  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  final View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_wheel_page_layout, null);
  dialog.getWindow().setContentView(view);
  final WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
  params.gravity = Gravity.CENTER;
  dialog.getWindow().setAttributes(params);
  dialog.setCanceledOnTouchOutside(true);
  return dialog;
}

代码示例来源:origin: chuyangliu/tastysnake

private void init() {
  View v = LayoutInflater.from(context).inflate(R.layout.dialog_help, null);
  initInfoTxt(v);
  Window window = getWindow();
  if (window != null) {
    window.setContentView(v);
    window.setWindowAnimations(R.style.DialogAnim);
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(lp);
  }
}

代码示例来源:origin: ThinkBear/GrabRedPacket

private void doInitView() {
  this.dialog = new AlertDialog.Builder(activity).create();
  this.dialog.show();
  // 关键在下面的两行,使用window.setContentView,替换整个对话框窗口的布局
  Window window = dialog.getWindow();
  window.setBackgroundDrawable(new ColorDrawable(0x00000000));
  window.setWindowAnimations(R.style.popup_anim_style_a);
  window.setContentView(R.layout.popup_dialog);
  this.messageView = (TextView) window.findViewById(R.id.message);
  this.yes = (TextView) window.findViewById(R.id.yes);
  this.no = (TextView) window.findViewById(R.id.no);
  this.myClickEvent = new MyClickEvent();
}

代码示例来源:origin: MiEcosystem/mijiaSDK

public void installContent() {
  /* We use a custom title so never request a window title */
  mWindow.requestFeature(Window.FEATURE_NO_TITLE);
  mWindow.setGravity(mGravity);
  if (mView == null || !canTextInput(mView)) {
    mWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
        WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
  }
  mWindow.setContentView(mAlertDialogLayout);
  setupView();
}

代码示例来源:origin: Dawish/BriskTVLauncher

private void initFloatingWindow() {
  mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
  mWindow = PolicyCompat.createWindow(mContext);
  mWindow.setWindowManager(mWindowManager, null, null);
  mWindow.requestFeature(Window.FEATURE_NO_TITLE);
  mDecor = mWindow.getDecorView();
  mDecor.setOnTouchListener(mTouchListener);
  mWindow.setContentView(this);
  mWindow.setBackgroundDrawableResource(android.R.color.transparent);
  
  // While the media controller is up, the volume control keys should
  // affect the media stream type
  mWindow.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  setFocusable(true);
  setFocusableInTouchMode(true);
  setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
  requestFocus();
}

相关文章

微信公众号

最新文章

更多

Window类方法