android.widget.LinearLayout#setMinimumWidth ( )源码实例Demo

下面列出了android.widget.LinearLayout#setMinimumWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: UIWidget   文件: UIAlertDialog.java
private View createContentView() {
    mLLayoutRoot = new LinearLayout(mContext);
    mLLayoutRoot.setId(R.id.lLayout_rootAlertDialog);
    mLLayoutRoot.setOrientation(LinearLayout.VERTICAL);
    mLLayoutRoot.setMinimumWidth(mMinWidth);
    mLLayoutRoot.setMinimumHeight(mMinHeight);
    setRootView();
    if (createBeforeTitle() != null) {
        mLLayoutRoot.addView(createBeforeTitle());
    }
    createTitle();
    createMessage();
    createContainerView();
    mLLayoutRoot.setPadding(0, 0, 0, 0);
    for (View v : createButtons()) {
        if (v != null) {
            mLLayoutRoot.addView(v);
        }
    }
    return mLLayoutRoot;
}
 
源代码2 项目: GravityBox   文件: ColorPickerPreference.java
private void setPreviewColor() {
	if (mView == null) return;
	ImageView iView = new ImageView(getContext());
	LinearLayout widgetFrameView = ((LinearLayout)mView.findViewById(android.R.id.widget_frame));
	if (widgetFrameView == null) return;
	widgetFrameView.setVisibility(View.VISIBLE);
	widgetFrameView.setPadding(
		widgetFrameView.getPaddingLeft(),
		widgetFrameView.getPaddingTop(),
		(int)(mDensity * 8),
		widgetFrameView.getPaddingBottom()
	);
	// remove already create preview image
	int count = widgetFrameView.getChildCount();
	if (count > 0) {
		widgetFrameView.removeViews(0, count);
	}
	widgetFrameView.addView(iView);
	widgetFrameView.setMinimumWidth(0);
	iView.setBackground(new AlphaPatternDrawable((int)(5 * mDensity)));
	iView.setImageBitmap(getPreviewBitmap());
}
 
@SuppressLint("NewApi")
private LinearLayout getLayout(final Activity activity, final Dialog dlg,
		ActionSheetConfig actionSheetConfig,
		final OnActionSheetItemSelected actionSheetItemSelected) {

	LayoutInflater inflater = (LayoutInflater) activity
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	LinearLayout layout = (LinearLayout) inflater.inflate(
			R.layout.widget_actionsheet_wechat_style, null);

	final int cFullFillWidth = 10000;
	layout.setMinimumWidth(cFullFillWidth);

	itemsCreat(activity, dlg, actionSheetConfig, actionSheetItemSelected,
			layout);

	return layout;
}
 
源代码4 项目: droidddle   文件: ThemeListPreference.java
private void setPreviewColor() {
    if (mView == null)
        return;
    ImageView iView = new ImageView(getContext());
    LinearLayout widgetFrameView = ((LinearLayout) mView.findViewById(android.R.id.widget_frame));
    if (widgetFrameView == null)
        return;
    widgetFrameView.setVisibility(View.VISIBLE);
    widgetFrameView.setPadding(widgetFrameView.getPaddingLeft(), widgetFrameView.getPaddingTop(), (int) (mDensity * 8), widgetFrameView.getPaddingBottom());
    // remove already create preview image
    int count = widgetFrameView.getChildCount();
    if (count > 0) {
        widgetFrameView.removeViews(0, count);
    }
    widgetFrameView.addView(iView);
    widgetFrameView.setMinimumWidth(0);
    iView.setBackgroundDrawable(new AlphaPatternDrawable((int) (5 * mDensity)));
    iView.setImageBitmap(getPreviewBitmap(mDensity, colors[mEntryIndex]));
}
 
源代码5 项目: LyricHere   文件: ColorPickerPreference.java
private void setPreviewColor() {
    if (mView == null) return;
    ImageView iView = new ImageView(getContext());
    LinearLayout widgetFrameView = ((LinearLayout) mView.findViewById(android.R.id.widget_frame));
    if (widgetFrameView == null) return;
    widgetFrameView.setVisibility(View.VISIBLE);
    widgetFrameView.setPadding(
            widgetFrameView.getPaddingLeft(),
            widgetFrameView.getPaddingTop(),
            (int) (mDensity * 8),
            widgetFrameView.getPaddingBottom()
    );
    // remove already create preview image
    int count = widgetFrameView.getChildCount();
    if (count > 0) {
        widgetFrameView.removeViews(0, count);
    }
    widgetFrameView.addView(iView);
    widgetFrameView.setMinimumWidth(0);
    iView.setBackgroundDrawable(new AlphaPatternDrawable((int) (5 * mDensity)));
    iView.setImageBitmap(getPreviewBitmap());
}
 
源代码6 项目: WiFiKeyView   文件: ColorPickerPreference.java
@SuppressWarnings("deprecation")
private void setPreviewColor() {
       if (mView == null) return;
       ImageView iView = new ImageView(getContext());
       LinearLayout widgetFrameView = ((LinearLayout) mView.findViewById(android.R.id.widget_frame));
       if (widgetFrameView == null) return;
       widgetFrameView.setVisibility(View.VISIBLE);
       widgetFrameView.setPadding(
               widgetFrameView.getPaddingLeft(),
               widgetFrameView.getPaddingTop(),
               (int) (mDensity * 8),
               widgetFrameView.getPaddingBottom()
       );
       // remove already create preview image
       int count = widgetFrameView.getChildCount();
       if (count > 0) {
           widgetFrameView.removeViews(0, count);
       }
       widgetFrameView.addView(iView);
       widgetFrameView.setMinimumWidth(0);
       iView.setBackgroundDrawable(new AlphaPatternDrawable((int) (5 * mDensity)));
       iView.setImageBitmap(getPreviewBitmap());
   }
 
源代码7 项目: Hangar   文件: ColorPickerPreference.java
private void setPreviewColor() {
	if (mView == null) return;
	ImageView iView = new ImageView(getContext());
	LinearLayout widgetFrameView = ((LinearLayout)mView.findViewById(android.R.id.widget_frame));
	if (widgetFrameView == null) return;
	widgetFrameView.setVisibility(View.VISIBLE);
	widgetFrameView.setPadding(
		widgetFrameView.getPaddingLeft(),
		widgetFrameView.getPaddingTop(),
		(int)(mDensity * 8),
		widgetFrameView.getPaddingBottom()
	);
	// remove already create preview image
	int count = widgetFrameView.getChildCount();
	if (count > 0) {
		widgetFrameView.removeViews(0, count);
	}
	widgetFrameView.addView(iView);
	widgetFrameView.setMinimumWidth(0);
	iView.setBackgroundDrawable(new AlphaPatternDrawable((int)(5 * mDensity)));
	iView.setImageBitmap(getPreviewBitmap());
}
 
源代码8 项目: LibreTasks   文件: UtilUI.java
/**
 * Force-inflates a dialog main linear-layout to take max available screen space even though
 * contents might not occupy full screen size.
 */
public static void inflateDialog(LinearLayout layout) {
  WindowManager wm = (WindowManager) layout.getContext().getSystemService(
    Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();
  layout.setMinimumWidth(display.getWidth() - 30);
  layout.setMinimumHeight(display.getHeight() - 40);
}
 
源代码9 项目: BigApp_Discuz_Android   文件: ActionSheet4IOS.java
@SuppressLint("NewApi")
private LinearLayout getLayout(final Activity activity, final Dialog dlg,
		ActionSheetConfig actionSheetConfig,
		final OnActionSheetItemSelected actionSheetItemSelected) {

	LayoutInflater inflater = (LayoutInflater) activity
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	LinearLayout layout = (LinearLayout) inflater.inflate(
			R.layout.widget_actionsheet_ios_style, null);

	// switch (actionSheetConfig.actionsheetStyle) {
	//
	// case ACTIONSHEET_IOS:
	// layout = (LinearLayout) inflater.inflate(
	// R.layout.widget_actionsheet_ios_style, null);
	//
	// break;
	// case ACTIONSHEET_WECHAT:
	// layout = (LinearLayout) inflater.inflate(
	// R.layout.widget_actionsheet_wechat_style, null);
	// break;
	// default:
	// layout = (LinearLayout) inflater.inflate(
	// R.layout.widget_actionsheet_wechat_style, null);
	// }

	final int cFullFillWidth = 10000;
	layout.setMinimumWidth(cFullFillWidth);

	itemsCreat(activity, dlg, actionSheetConfig, actionSheetItemSelected,
			layout);

	return layout;
}
 
源代码10 项目: Telegram-FOSS   文件: FloatingToolbar.java
private View createMenuItemButton(Context context, MenuItem menuItem, int iconTextSpacing) {
    LinearLayout menuItemButton = new LinearLayout(context);
    menuItemButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    menuItemButton.setOrientation(LinearLayout.HORIZONTAL);
    menuItemButton.setMinimumWidth(AndroidUtilities.dp(48));
    menuItemButton.setMinimumHeight(AndroidUtilities.dp(48));
    menuItemButton.setPaddingRelative(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);

    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setFocusable(false);
    textView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    textView.setFocusableInTouchMode(false);
    if (currentStyle == STYLE_DIALOG) {
        textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    } else if (currentStyle == STYLE_BLACK) {
        textView.setTextColor(0xfffafafa);
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(0x40ffffff, false));
    } else if (currentStyle == STYLE_THEME) {
        textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    }
    textView.setPaddingRelative(AndroidUtilities.dp(11), 0, 0, 0);
    menuItemButton.addView(textView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, AndroidUtilities.dp(48)));
    if (menuItem != null) {
        updateMenuItemButton(menuItemButton, menuItem, iconTextSpacing);
    }
    return menuItemButton;
}
 
protected LinearLayout getSplashLayout() {
    // Get reference to display
    Display display = getWindowManager().getDefaultDisplay();

    LinearLayout root = new LinearLayout(getActivity());
    root.setMinimumHeight(display.getHeight());
    root.setMinimumWidth(display.getWidth());
    root.setOrientation(LinearLayout.VERTICAL);
    root.setBackgroundColor(getIntegerProperty("backgroundColor", Color.BLACK));
    root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
    root.setBackgroundResource(splashscreen);

    return root;
}
 
源代码12 项目: iGap-Android   文件: AbstractMessage.java
private void addSenderNameToGroupIfNeed(final View view, Realm realm) {

        if (G.showSenderNameInGroup) {
            final LinearLayout mContainer = (LinearLayout) view.findViewById(R.id.m_container);
            if (mContainer != null) {

                if (view.findViewById(R.id.messageSenderName) != null) {
                    mContainer.removeView(view.findViewById(R.id.messageSenderName));
                }

                if (view.findViewById(R.id.messageSenderName) == null) {
                    RealmRegisteredInfo realmRegisteredInfo = RealmRegisteredInfo.getRegistrationInfo(getRealmChat(), Long.parseLong(mMessage.senderID));
                    if (realmRegisteredInfo != null) {
                        final EmojiTextViewE _tv = (EmojiTextViewE) ViewMaker.makeHeaderTextView(realmRegisteredInfo.getDisplayName());

                        //_tv.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                        //    @Override
                        //    public void onGlobalLayout() {
                        //        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
                        //            _tv.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                        //        } else {
                        //            _tv.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                        //        }
                        //
                        //        if (_tv.getWidth() < mContainer.getWidth()) {
                        //            _tv.setWidth(mContainer.getWidth());
                        //        }
                        //    }
                        //});

                        _tv.measure(0, 0);       //must call measure!
                        int maxWith = 0;
                        maxWith = _tv.getMeasuredWidth() + ViewMaker.i_Dp(R.dimen.dp40);

                        if (minWith < maxWith) {
                            minWith = maxWith;
                        }
                        mContainer.setMinimumWidth(Math.min(minWith, G.maxChatBox));
                        mContainer.addView(_tv, 0, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
                    }
                }
            }
        }
    }
 
源代码13 项目: IoTgo_Android_App   文件: CordovaActivity.java
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
源代码14 项目: reader   文件: CordovaActivity.java
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
源代码15 项目: reader   文件: CordovaActivity.java
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
源代码16 项目: phonegapbootcampsite   文件: CordovaActivity.java
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
源代码19 项目: wildfly-samples   文件: CordovaActivity.java
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}