Java Code Examples for android.widget.LinearLayout#setMinimumWidth()

The following examples show how to use android.widget.LinearLayout#setMinimumWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorPickerPreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 2
Source File: UIAlertDialog.java    From UIWidget with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: ColorPickerPreference.java    From Hangar with GNU General Public License v3.0 6 votes vote down vote up
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());
}
 
Example 4
Source File: ActionSheet4WeChat.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 5
Source File: ColorPickerPreference.java    From WiFiKeyView with Apache License 2.0 6 votes vote down vote up
@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());
   }
 
Example 6
Source File: ThemeListPreference.java    From droidddle with Apache License 2.0 6 votes vote down vote up
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]));
}
 
Example 7
Source File: ColorPickerPreference.java    From LyricHere with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 8
Source File: CordovaActivity.java    From crosswalk-cordova-android with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: FloatingToolbar.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 10
Source File: ActionSheet4IOS.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 11
Source File: UtilUI.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: CordovaActivity.java    From reader with MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: CordovaActivity.java    From reader with MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: CordovaActivity.java    From IoTgo_Android_App with MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: CordovaActivity.java    From phonegapbootcampsite with MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 16
Source File: CordovaActivity.java    From CordovaYoutubeVideoPlayer with MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source File: CordovaActivity.java    From cordova-android-chromeview with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 18
Source File: CordovaActivity.java    From wildfly-samples with MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 19
Source File: CordovaActivity.java    From phonegap-plugin-loading-spinner with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: AbstractMessage.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
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));
                    }
                }
            }
        }
    }