當前位置: 首頁>>代碼示例>>Java>>正文


Java LayoutParams類代碼示例

本文整理匯總了Java中android.view.WindowManager.LayoutParams的典型用法代碼示例。如果您正苦於以下問題:Java LayoutParams類的具體用法?Java LayoutParams怎麽用?Java LayoutParams使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LayoutParams類屬於android.view.WindowManager包,在下文中一共展示了LayoutParams類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = this.getIntent();
    Bundle bl = intent.getExtras();
    if (bl != null) {
        title = bl.getString(KEY_TITILE);
        mDir = bl.getString(KEY_PATH);
    }

    setTitle(title);
    mData = getData();
    MyAdapter adapter = new MyAdapter(this);
    setListAdapter(adapter);
    getListView().setOnScrollListener(listener);

    // 固定對話框大小
    LayoutParams p = getWindow().getAttributes();
    p.height = (int) (getResources().getDisplayMetrics().heightPixels * 0.8);
    p.width = (int) (getResources().getDisplayMetrics().widthPixels * 0.95);
    getWindow().setAttributes(p);

}
 
開發者ID:tohodog,項目名稱:QSVideoPlayer,代碼行數:25,代碼來源:ExSelectDialog.java

示例2: centerWindow

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
private static void centerWindow(Window w) {
    DisplayMetrics metrics = new DisplayMetrics();
    Display display = w.getWindowManager().getDefaultDisplay();
    display.getMetrics(metrics);

    int width = Math.min(metrics.widthPixels - (int) (2 * DLG_PADDING_DP * metrics.density),
            (int) (MAX_DIALOG_WIDTH_DP * metrics.density));
    int height = Math.min(metrics.heightPixels - (int) ((2 * DLG_PADDING_DP + APPROX_STATUSBAR_HEIGHT_DP) * metrics.density),
            (int) (MAX_DIALOG_HEIGHT_DP * metrics.density));

    int x = (metrics.widthPixels - width) / 2;
    int y = (metrics.heightPixels - height - ((int) (APPROX_STATUSBAR_HEIGHT_DP * metrics.density))) / 2;

    LayoutParams params = w.getAttributes();
    params.x = x;
    params.y = y;
    params.width = width;
    params.height = height;
    w.setAttributes(params);
    w.setGravity(Gravity.LEFT | Gravity.TOP);
}
 
開發者ID:monsieurh,項目名稱:homebank_android,代碼行數:22,代碼來源:AppStoreInterstitial.java

示例3: setBrightness

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
private void setBrightness(double brightness) {
    if (brightness > BRIGHTNESS_MAX_LEVEL) {
        Logger.getInstance().Error(TAG, "Brightness to high! Set to maximum level!");
        brightness = BRIGHTNESS_MAX_LEVEL;
    }

    if (brightness < BRIGHTNESS_MIN_LEVEL) {
        Logger.getInstance().Error(TAG, "Brightness to low! Set to minimum level!");
        brightness = BRIGHTNESS_MIN_LEVEL;
    }

    ContentResolver contentResolver = _context.getContentResolver();
    Window window = ((Activity) _context).getWindow();

    try {
        Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS, (int) (brightness * 255));
        LayoutParams layoutParams = window.getAttributes();
        layoutParams.screenBrightness = (float) brightness;
        window.setAttributes(layoutParams);
    } catch (Exception e) {
        Logger.getInstance().Error(TAG, e.toString());
        Toasty.error(_context, "Failed to set brightness!", Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:25,代碼來源:DisplayController.java

示例4: displayListViewDialog

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
private static void displayListViewDialog(@NonNull Context context, @NonNull String title, @NonNull ArrayList<String> list) {
    final android.app.Dialog dialog = new android.app.Dialog(context);

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_listview);

    TextView titleView = dialog.findViewById(R.id.dialog_title_text_view);
    titleView.setText(title);

    com.rey.material.widget.Button closeButton = dialog.findViewById(R.id.dialog_button_close);
    closeButton.setOnClickListener(v -> dialog.dismiss());

    ListView listView = dialog.findViewById(R.id.dialog_list_view);
    listView.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_dropdown_item_1line, list));

    dialog.setCancelable(true);
    dialog.show();

    Window window = dialog.getWindow();
    if (window != null) {
        window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    }
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:24,代碼來源:MapContentBuilder.java

示例5: addTabViewToWindow

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
private void addTabViewToWindow(View view, int x, int y, int w, int h, Boolean touchable) {
    int flags = 16843544;
    if (!touchable.booleanValue()) {
        flags = 16843544 | 16;
    }
    LayoutParams params = new LayoutParams(-2, -2, 2007, flags, -3);
    params.gravity = 51;
    params.width = w;
    params.height = h;
    params.x = x;
    params.y = y;
    try {
        Field privateFlags = params.getClass().getDeclaredField("privateFlags");
        privateFlags.setInt(params, privateFlags.getInt(params) | 64);
    } catch (NoSuchFieldException ex) {
        ex.printStackTrace();
    } catch (IllegalAccessException ex2) {
        ex2.printStackTrace();
    }
    getWindowManager().addView(view, params);
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:22,代碼來源:SwipeTabViewController.java

示例6: addInboxBodyToWindow

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
void addInboxBodyToWindow(int windowType) {
    if (windowType == 2010 || windowType == 2007) {
        Log.d(TAG, "add Tray()");
        WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
        LayoutParams params = new LayoutParams(-2, -2, windowType, 16843544, -3);
        params.gravity = 51;
        params.width = -1;
        params.height = -1;
        params.x = (int) FAR_AWAY;
        params.y = 0;
        windowManager.addView(this.shadeInboxBody, params);
        this.shadeInboxBody.setVisibility(View.INVISIBLE);
        return;
    }
    Log.d(TAG, "Unrecognized Window Type: addInboxBodyToWindow()");
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:17,代碼來源:ShadeViewManager.java

示例7: show

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
public void show(IBinder windowToken) {
    MenuBuilder menu = this.mMenu;
    Builder builder = new Builder(menu.getContext());
    this.mPresenter = new ListMenuPresenter(builder.getContext(), R.layout.abc_list_menu_item_layout);
    this.mPresenter.setCallback(this);
    this.mMenu.addMenuPresenter(this.mPresenter);
    builder.setAdapter(this.mPresenter.getAdapter(), this);
    View headerView = menu.getHeaderView();
    if (headerView != null) {
        builder.setCustomTitle(headerView);
    } else {
        builder.setIcon(menu.getHeaderIcon()).setTitle(menu.getHeaderTitle());
    }
    builder.setOnKeyListener(this);
    this.mDialog = builder.create();
    this.mDialog.setOnDismissListener(this);
    LayoutParams lp = this.mDialog.getWindow().getAttributes();
    lp.type = CloseFrame.REFUSE;
    if (windowToken != null) {
        lp.token = windowToken;
    }
    lp.flags |= 131072;
    this.mDialog.show();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:MenuDialogHelper.java

示例8: createWindowLayoutParams

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
private LayoutParams createWindowLayoutParams() {
    LayoutParams lp = new LayoutParams();
    if (VERSION.SDK_INT >= 19) {
        lp.type = 2005;
    } else {
        lp.type = 2002;
    }
    lp.flags |= 8;
    lp.alpha = 1.0f;
    lp.gravity = 83;
    lp.x = 0;
    lp.y = 0;
    lp.width = FLOATING_WINDOW_WIDTH;
    lp.height = FLOATING_WINDOW_HEIGHT;
    lp.format = 1;
    return lp;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:18,代碼來源:FloatingWindowPlayerView.java

示例9: a

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
private void a() {
    this.b = new TextView(this.a.F);
    this.b.setTextColor(Color.rgb(255, 255, 255));
    this.b.setTextSize(15.0f);
    this.b.setShadowLayer(1.0f, 1.0f, 1.0f, Color.rgb(242, 211, 199));
    this.b.setGravity(3);
    this.b.setEllipsize(TruncateAt.END);
    this.b.setIncludeFontPadding(false);
    this.b.setSingleLine(true);
    ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, -2);
    layoutParams.weight = 1.0f;
    layoutParams.leftMargin = this.a.a(4);
    addView(this.b, layoutParams);
    this.c = new Button(this.a.F);
    this.c.setPadding(0, 0, 0, 0);
    this.c.setTextSize(16.0f);
    this.c.setTextColor(Color.rgb(255, 255, 255));
    this.c.setShadowLayer(1.0f, 1.0f, 1.0f, Color.rgb(242, 211, 199));
    this.c.setIncludeFontPadding(false);
    this.c.setOnClickListener(new f(this.a, this.d.a));
    layoutParams = new LinearLayout.LayoutParams(this.a.a(TaskGuide.p), this.a.a(TaskGuide.q));
    layoutParams.leftMargin = this.a.a(2);
    layoutParams.rightMargin = this.a.a(8);
    addView(this.c, layoutParams);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:26,代碼來源:TaskGuide.java

示例10: b

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
private ViewGroup b(Context context) {
    ViewGroup eVar = new e(this, context);
    g[] gVarArr = this.h.c;
    View iVar;
    ViewGroup.LayoutParams layoutParams;
    if (gVarArr.length == 1) {
        iVar = new i(this, context, gVarArr[0]);
        iVar.setId(1);
        layoutParams = new RelativeLayout.LayoutParams(-1, -2);
        layoutParams.addRule(15);
        eVar.addView(iVar, layoutParams);
    } else {
        iVar = new i(this, context, gVarArr[0]);
        iVar.setId(1);
        View iVar2 = new i(this, context, gVarArr[1]);
        iVar2.setId(2);
        layoutParams = new RelativeLayout.LayoutParams(-1, -2);
        layoutParams.addRule(14);
        layoutParams.setMargins(0, a(6), 0, 0);
        ViewGroup.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -2);
        layoutParams2.addRule(14);
        layoutParams2.setMargins(0, a(4), 0, 0);
        layoutParams2.addRule(3, 1);
        layoutParams2.addRule(5, 1);
        eVar.addView(iVar, layoutParams);
        eVar.addView(iVar2, layoutParams2);
    }
    eVar.setBackgroundDrawable(e());
    return eVar;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:31,代碼來源:TaskGuide.java

示例11: onCreate

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.flashlight);
	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

	SettingsApplication app = (SettingsApplication) getApplication();
	String value = app.getPreferences().getString(Constants.PREF_FLASHLIGHT_SWITCH, "0");
	switch (Integer.parseInt(value)) {
		case 1:
			mSwitchDetector = new DelaySwitchDetector(this);
			break;
		case 2:
			mSwitchDetector = new ShakeSwitchDeterctor(this);
			break;
		default:
			mSwitchDetector = new OrientationSwitchDetector(this);
			break;
	}
	
	mMessage = (TextView) findViewById(R.id.text);
	mMessage.setText(mSwitchDetector.getTextId());

}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:26,代碼來源:ScreenLightActivity.java

示例12: run

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
public void run() {
	
	RangeSetting setting = (RangeSetting) mSetting;
	
	// convert from 100 basis to 255 basis
	int value = getPropertyValue(setting.value);
	
	// update current view's brightness
	LayoutParams attrs = mAttrs;
	if (attrs == null) {
		attrs = mActivity.getWindow().getAttributes();
		mAttrs = attrs;
	}
	attrs.screenBrightness = value / (float)getMaximum();
	
	// request brightness update
	Window window = mActivity.getWindow();
	window.setAttributes(attrs);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:20,代碼來源:BrightnessSettingHandler.java

示例13: setAutobrightness

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
protected void setAutobrightness(Activity activity, ContentResolver resolver, boolean on) {
	super.setAutobrightness(activity, resolver, on);
	
	// set auto brightness on/off
	int value = on ? 255 : 128; // auto or middle brightness
	Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS, value);

	if (!on) {
		// update slider
		RangeSetting setting = (RangeSetting) mSetting;
		setting.value = getPercentValue(value);
		setting.descr = null;
		setting.enabled = false;
		setting.checked = false; 
		setting.updateView();
	}
	
	// update current view's brightness
	LayoutParams attrs = mActivity.getWindow().getAttributes();
	attrs.screenBrightness = on ? 1f : value / (float) getMaximum();
	
	// request brightness update
	Window window = mActivity.getWindow();
	window.setAttributes(attrs);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:26,代碼來源:BrightnessSettingHandlerX10.java

示例14: FileChooser

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
public FileChooser(Activity activity, File initialPath) {
    this.activity = activity;
    dialog = new Dialog(activity);
    list = new ListView(activity);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override public void onItemClick(AdapterView<?> parent, View view, int which, long id) {
            String fileChosen = (String) list.getItemAtPosition(which);
            File chosenFile = getChosenFile(fileChosen);
            if (chosenFile.isDirectory()) {
                refresh(chosenFile);
            } else {
                if (fileListener != null) {
                    fileListener.fileSelected(chosenFile);
                }
                dialog.dismiss();
            }
        }
    });
    dialog.setContentView(list);
    dialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    if (initialPath != null) {
        refresh(initialPath);
    }else{
        refresh(Environment.getExternalStorageDirectory());
    }
}
 
開發者ID:chooka888,項目名稱:BluetoothDuck,代碼行數:27,代碼來源:FileChooser.java

示例15: setStatusBarDarkIcon

import android.view.WindowManager.LayoutParams; //導入依賴的package包/類
public static boolean setStatusBarDarkIcon(Window window, boolean dark) {
    if (window == null) {
        return false;
    }
    try {
        LayoutParams lp = window.getAttributes();
        Field darkFlag = LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
        Field meizuFlags = LayoutParams.class.getDeclaredField("meizuFlags");
        darkFlag.setAccessible(true);
        meizuFlags.setAccessible(true);
        int bit = darkFlag.getInt(null);
        int value = meizuFlags.getInt(lp);
        if (dark) {
            value |= bit;
        } else {
            value &= bit ^ -1;
        }
        meizuFlags.setInt(lp, value);
        window.setAttributes(lp);
        return true;
    } catch (Exception e) {
        Log.e(TAG, "setStatusBarDarkIcon: failed");
        return false;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:26,代碼來源:StatusBarProxy.java


注:本文中的android.view.WindowManager.LayoutParams類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。