Java Code Examples for android.view.ViewGroup.LayoutParams

The following examples show how to use android.view.ViewGroup.LayoutParams. These examples are extracted from open source projects. 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 Project: Indic-Keyboard   Source File: LatinIME.java    License: Apache License 2.0 6 votes vote down vote up
private void showOptionDialog(final AlertDialog dialog) {
    final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
    if (windowToken == null) {
        return;
    }

    final Window window = dialog.getWindow();
    final WindowManager.LayoutParams lp = window.getAttributes();
    lp.token = windowToken;
    lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
    window.setAttributes(lp);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    mOptionsDialog = dialog;
    dialog.show();
}
 
Example 2
Source Project: POCenter   Source File: EditPage.java    License: MIT License 6 votes vote down vote up
public void setActivity(Activity activity) {
		super.setActivity(activity);
		if (isDialogMode()) {
			System.err.println("Theme classic does not support dialog mode!");
//			activity.setTheme(android.R.style.Theme_Dialog);
//			activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
//			if (Build.VERSION.SDK_INT >= 11) {
//				try {
//					ReflectHelper.invokeInstanceMethod(activity, "setFinishOnTouchOutside", false);
//				} catch (Throwable e) {}
//			}
		}

		activity.getWindow().setSoftInputMode(
				WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE |
				WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
	}
 
Example 3
Source Project: Leanplum-Android-SDK   Source File: BaseMessageDialog.java    License: Apache License 2.0 6 votes vote down vote up
private CloseButton createCloseButton(Activity context, boolean fullscreen, View parent) {
  CloseButton closeButton = new CloseButton(context);
  closeButton.setId(R.id.close_button);
  RelativeLayout.LayoutParams closeLayout = new RelativeLayout.LayoutParams(
      LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  if (fullscreen) {
    closeLayout.addRule(RelativeLayout.ALIGN_PARENT_TOP, dialogView.getId());
    closeLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, dialogView.getId());
    closeLayout.setMargins(0, SizeUtil.dp5, SizeUtil.dp5, 0);
  } else {
    closeLayout.addRule(RelativeLayout.ALIGN_TOP, parent.getId());
    closeLayout.addRule(RelativeLayout.ALIGN_RIGHT, parent.getId());
    closeLayout.setMargins(0, -SizeUtil.dp7, -SizeUtil.dp7, 0);
  }
  closeButton.setLayoutParams(closeLayout);
  closeButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View arg0) {
      cancel();
    }
  });
  return closeButton;
}
 
Example 4
Source Project: Leanplum-Android-SDK   Source File: BaseMessageDialog.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private ImageView createBackgroundImageView(Context context, boolean fullscreen) {
  BackgroundImageView view = new BackgroundImageView(context, fullscreen);
  view.setScaleType(ImageView.ScaleType.CENTER_CROP);
  int cornerRadius;
  if (!fullscreen) {
    cornerRadius = SizeUtil.dp20;
  } else {
    cornerRadius = 0;
  }
  view.setImageBitmap(options.getBackgroundImage());
  ShapeDrawable footerBackground = new ShapeDrawable();
  footerBackground.setShape(createRoundRect(cornerRadius));
  footerBackground.getPaint().setColor(options.getBackgroundColor());
  if (Build.VERSION.SDK_INT >= 16) {
    view.setBackground(footerBackground);
  } else {
    view.setBackgroundDrawable(footerBackground);
  }
  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  view.setLayoutParams(layoutParams);
  return view;
}
 
Example 5
Source Project: UltimateAndroid   Source File: JazzyViewActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, final int position) {
	TextView text = new TextView(JazzyViewActivity.this);
	text.setGravity(Gravity.CENTER);
	text.setTextSize(30);
	text.setTextColor(Color.WHITE);
	text.setText("Page " + position);
	text.setPadding(30, 30, 30, 30);
	int bg = Color.rgb((int) Math.floor(Math.random()*128)+64, 
			(int) Math.floor(Math.random()*128)+64,
			(int) Math.floor(Math.random()*128)+64);
	text.setBackgroundColor(bg);
	container.addView(text, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	mJazzy.setObjectForPosition(text, position);
	return text;
}
 
Example 6
Source Project: BigApp_Discuz_Android   Source File: DialogActAgree.java    License: Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
    View view = LayoutInflater.from(context).inflate(
            R.layout.dialog_act_agree, null);
    dialog = new Dialog(context, R.style.Dialog_act_agree);
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(view);

    Window window = dialog.getWindow();
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.gravity = Gravity.BOTTOM;
    lp.width = LayoutParams.MATCH_PARENT;
    window.setWindowAnimations(R.style.dialogWindowAnim);

    view.findViewById(R.id.ll_agree).setOnClickListener(this);
    view.findViewById(R.id.ll_refuse).setOnClickListener(this);
}
 
Example 7
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {

	View rootView = inflater.inflate(R.layout.found_fragment, container,
			false);

	cursor = (ImageView) rootView.findViewById(R.id.cursor);
	DisplayMetrics dm = new DisplayMetrics();
	getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
	int screenW = dm.widthPixels;// ��ȡ�ֱ��ʿ��
	LayoutParams ps = cursor.getLayoutParams();
	ps.width = screenW / 3;
	cursor.setLayoutParams(ps);
	t1 = (TextView) rootView.findViewById(R.id.text1);
	t2 = (TextView) rootView.findViewById(R.id.text2);
	t3 = (TextView) rootView.findViewById(R.id.text3);
	viewPager = (ViewPager) rootView.findViewById(R.id.foundpager);
	InitTextView();
	InitImageView();
	InitViewPager();
	return rootView;
}
 
Example 8
Source Project: ZoomImageView   Source File: ViewPagerSampleActivity.java    License: Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /*
     * Use full screen window and translucent action bar
     */
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().setBackgroundDrawable(new ColorDrawable(0xFF000000));
    if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
        getActionBar().setBackgroundDrawable(new ColorDrawable(0x88000000));
        // Note: if you use ActionBarSherlock use here getSupportActionBar()
    }

    setContentView(R.layout.view_pager);

    ViewPager viewPager = (ViewPager) findViewById(R.id.zoomViewPager);
    viewPager.setAdapter(new SamplePagerAdapter());

    // Add margin between pages (optional)
    viewPager.setPageMargin((int) getResources().getDisplayMetrics().density * 10);
}
 
Example 9
Source Project: jitsi-android   Source File: GlobalStatusMenu.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * On pre show
 */
protected void preShow()
{
    if (mRootView == null) 
        throw new IllegalStateException(
            "setContentView was not called with a view to display.");

    onShow();

    if (mBackground == null) 
        mWindow.setBackgroundDrawable(new BitmapDrawable());
    else 
        mWindow.setBackgroundDrawable(mBackground);

    mWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
    mWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    mWindow.setTouchable(true);
    mWindow.setFocusable(true);
    mWindow.setOutsideTouchable(true);

    mWindow.setContentView(mRootView);
}
 
Example 10
Source Project: KlyphMessenger   Source File: MainActivity.java    License: MIT License 6 votes vote down vote up
private void setPortraitMode()
{
	SlidingPaneLayout.LayoutParams params = (SlidingPaneLayout.LayoutParams) rightContainer.getLayoutParams();
	params.width = KlyphDevice.getDeviceWidth();// rightContainerWidth;
	// params.leftMargin = paddingLeft;
	params.rightMargin = 0;
	rightContainer.setLayoutParams(params);

	params = (SlidingPaneLayout.LayoutParams) leftContainer.getLayoutParams();
	params.width = leftContainerWidth;
	params.leftMargin = 0;
	params.rightMargin = 0;
	leftContainer.setLayoutParams(params);

	slidingPane.requestLayout();
}
 
Example 11
Source Project: letv   Source File: MoreFloatingDialog.java    License: Apache License 2.0 6 votes vote down vote up
private TextView addShareItemText(Drawable drawable, String str) {
    if (drawable != null) {
        drawable.setBounds(0, 0, dip2px(SHARE_ICON_SIZE), dip2px(SHARE_ICON_SIZE));
    }
    View textView = new TextView(getContext());
    textView.setTextColor(-1);
    textView.setCompoundDrawables(null, drawable, null, null);
    textView.setTextSize(13.0f);
    textView.setCompoundDrawablePadding(dip2px(8.0f));
    textView.setPadding(0, dip2px(19.0f), 0, dip2px(19.0f));
    textView.setGravity(1);
    textView.setText(str);
    LayoutParams layoutParams = new LinearLayout.LayoutParams(0, -2);
    layoutParams.weight = 1.0f;
    layoutParams.gravity = 1;
    this.mRootView.addView(textView, layoutParams);
    addHorizontalDivider();
    return textView;
}
 
Example 12
public void showChart(View v) {
	LinearLayout mainLayout = (LinearLayout) findViewById(R.id.layout_chart_fragment);

	try {
		View testChartView = findViewById(100); // TODO: ...
		mainLayout.removeView(testChartView);
	} catch (Exception e) {
		// e.printStackTrace();
	}

	v.setId(100); // TODO: what's safe?

	// add to layout
	LayoutParams lparams = new LayoutParams(LayoutParams.MATCH_PARENT,
			LayoutParams.MATCH_PARENT);

	v.setBackgroundColor(Color.rgb(238, 238, 238));
	v.setLayoutParams(lparams);
	if (mainLayout == null) {
		// log("ERROR layout null, chart");
		return;
	}
	mainLayout.addView(v);
}
 
Example 13
/**
 * Create a new row view.
 */
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    // create a row view
    LinearLayout row = new LinearLayout(context);
    row.setWeightSum(numColumns);

    V[] gridItemViewHolders = newGridItemViewHolderArray(numColumns);

    // inflate a grid item view for each column in the row
    for (int col = 0; col < numColumns; col++) {
        View gridItemView = newGridItemView(context, cursor, parent);
        LinearLayout.LayoutParams lp = newGridItemLayoutParams(col);

        gridItemViewHolders[col] = newGridItemViewHolder(gridItemView);
        row.addView(gridItemView, lp);
    }

    // save the grid item view holders in the row view holder
    RowViewHolder holder = new RowViewHolder(gridItemViewHolders);
    row.setTag(holder);
    return row;
}
 
Example 14
private void startOverLayFriend() {
    SlideInContactsLayout overlayContactsLayout = (SlideInContactsLayout) getLayoutInflater().inflate(
            R.layout.overlay_contacts, null, false);
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            PixelFormat.TRANSLUCENT
    );
    getWindowManager().addView(overlayContactsLayout, params);

    TypedValue tv = new TypedValue();
    int actionBarHeight =
            getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true) ?
                    TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()) : 0;

    overlayContactsLayout.start(this, Friend.lorem, actionBarHeight);
}
 
Example 15
Source Project: letv   Source File: MoreFloatingDialog.java    License: Apache License 2.0 6 votes vote down vote up
public MoreFloatingDialog(Context context) {
    super(context, 16973840);
    WindowManager windowManager = (WindowManager) context.getSystemService("window");
    DisplayMetrics displayMetrics = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(displayMetrics);
    this.density = displayMetrics.density;
    f.b(f.d, "-->(MoreFloatingDialog) : density = " + this.density);
    LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
    this.mContentView = new RelativeLayout(context);
    this.mContentView.setLayoutParams(layoutParams);
    this.mContentView.setBackgroundDrawable(a.a(SOURCE_FLOATING_BG, context, this.ninePatchRect));
    this.mRootView = new LinearLayout(context);
    layoutParams = new LinearLayout.LayoutParams(-1, -2);
    this.mRootView.setLayoutParams(layoutParams);
    this.mShareItems.put(SOURCE_QQ_BG, addShareItemText(a.a(SOURCE_QQ_BG, getContext(), this.ninePatchRect), "QQ分享"));
    this.mShareItems.put(SOURCE_QZONE_BG, addShareItemText(a.a(SOURCE_QZONE_BG, getContext(), this.ninePatchRect), "空间分享"));
    this.mContentView.addView(this.mRootView, layoutParams);
    setContentView(this.mContentView);
}
 
Example 16
Source Project: PHONK   Source File: PPopupDialogFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void calculateSize() {
    Window window = getDialog().getWindow();
    Point size = new Point();
    Display display = window.getWindowManager().getDefaultDisplay();
    display.getSize(size);

    if (mW < 0) {
        mWidth = WindowManager.LayoutParams.WRAP_CONTENT;
    } else if (mW > 1) {
        mWidth = WindowManager.LayoutParams.MATCH_PARENT;
    } else {
        mWidth = (int) (size.x * mW);
    }

    if (mH < 0) {
        mHeight = WindowManager.LayoutParams.WRAP_CONTENT;
    } else if (mH > 1) {
        mHeight = WindowManager.LayoutParams.MATCH_PARENT;
    } else {
        mHeight = (int) (size.y * mH);
    }
}
 
Example 17
Source Project: YCDialog   Source File: CustomSelectDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 当对话框启动的时候被调用
 */
@Override
protected void onStart() {
    super.onStart();
    //设置弹窗的位置时在底部
    Window window = getWindow();
    // 设置显示动画
    if (window != null) {
        window.setWindowAnimations(R.style.BottomDialogAnimationStyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = mActivity.getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = LayoutParams.MATCH_PARENT;
        wl.height = LayoutParams.WRAP_CONTENT;
        // 设置显示位置
        onWindowAttributesChanged(wl);
    }
}
 
Example 18
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {
    et = new EditText(c);
    et.setBackgroundResource(R.drawable.oval);
    et.setTextColor(c.getResources()
            .getColorStateList(R.color.primary_text_holo_light));
    et.setText(answer);
    et.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT));
    if (!NumericType.NONE.equals(numericType)) {
        KeyListener listener = getKeyListenerForType(numericType);
        if (listener != null)
            et.setKeyListener(listener);
    } else {
        et.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
                TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    }
    return encapsulateQuestion(c, et);
}
 
Example 19
Source Project: VideoRecorder   Source File: FFmpegRecorderActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
	isFinalizing = true;
	recordFinish = true;
	runAudioThread = false;
	
	//创建处理进度条
	creatingProgress= new Dialog(FFmpegRecorderActivity.this,R.style.Dialog_loading_noDim);
	Window dialogWindow = creatingProgress.getWindow();
	WindowManager.LayoutParams lp = dialogWindow.getAttributes();
	lp.width = (int) (getResources().getDisplayMetrics().density*240);
	lp.height = (int) (getResources().getDisplayMetrics().density*80);
	lp.gravity = Gravity.CENTER;
	dialogWindow.setAttributes(lp);
	creatingProgress.setCanceledOnTouchOutside(false);
	creatingProgress.setContentView(R.layout.activity_recorder_progress);
	
	progress = (TextView) creatingProgress.findViewById(R.id.recorder_progress_progresstext);
	bar = (ProgressBar) creatingProgress.findViewById(R.id.recorder_progress_progressbar);
	creatingProgress.show();


	
	//txtTimer.setVisibility(View.INVISIBLE);
	//handler.removeCallbacks(mUpdateTimeTask);
	super.onPreExecute();
}
 
Example 20
Source Project: LibreTasks   Source File: ActivityDlgActionInput.java    License: Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  ImageView iv = new ImageView(context);
  iv.setImageResource(attributes.get(position).getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  TextView tv = new TextView(context);
  tv.setText(attributes.get(position).getDescriptionShort());
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(0xFFFFFFFF);
  tv.setMinHeight(46);

  ll.addView(iv);
  ll.addView(tv);

  return ll;
}
 
Example 21
Source Project: AndroidTranslucentUI   Source File: BaseActivity.java    License: Apache License 2.0 5 votes vote down vote up
protected void setContentLayout(int viewId) {
	LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	contentView = inflater.inflate(viewId, null);
	LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
			LayoutParams.MATCH_PARENT);
	contentView.setLayoutParams(layoutParams);
	if (null != rootContent) {
		rootContent.addView(contentView);
	}
}
 
Example 22
private void init() {
	View view = LayoutInflater.from(mContext).inflate(
			R.layout.zg_widget_pop_media_catalog, null);
	ListView listView = (ListView) view.findViewById(R.id.listview);
	mPopupWindow = new PopupWindow(view, LayoutParams.MATCH_PARENT,
			LayoutParams.WRAP_CONTENT);
	mAdapter = new MediaCatalogAdapter(mContext, mMediaType);
	mAdapter.setFiles(mCatalogs);
	listView.setAdapter(mAdapter);
	listView.setOnItemClickListener(this);
	mPopupWindow.setFocusable(true);
	mPopupWindow.setOutsideTouchable(true);
	mPopupWindow.setBackgroundDrawable(new ColorDrawable(0));
}
 
Example 23
Source Project: adt-leanback-support   Source File: ListRowPresenter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View createWrapper(View root) {
    ShadowOverlayContainer wrapper = new ShadowOverlayContainer(root.getContext());
    wrapper.setLayoutParams(
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    wrapper.initialize(needsDefaultShadow(),
            needsDefaultListSelectEffect(),
            areChildRoundedCornersEnabled());
    return wrapper;
}
 
Example 24
Source Project: LQRWeChat   Source File: EditPage.java    License: MIT License 5 votes vote down vote up
public void setActivity(Activity activity) {
		super.setActivity(activity);
		if (isDialogMode()) {
//			activity.setTheme(android.R.style.Theme_Dialog);
//			activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
//			if (Build.VERSION.SDK_INT >= 11) {
//				try {
//					ReflectHelper.invokeInstanceMethod(activity, "setFinishOnTouchOutside", false);
//				} catch (Throwable e) {}
//			}
		}

		activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
				| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
	}
 
Example 25
Source Project: BigApp_Discuz_Android   Source File: WheelView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Calculates control width and creates text layouts
 * 
 * @param widthSize
 *            the input layout width
 * @param mode
 *            the layout mode
 * @return the calculated control width
 */
private int calculateLayoutWidth(int widthSize, int mode) {
	initResourcesIfNecessary();

	// TODO: make it static
	itemsLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
			LayoutParams.WRAP_CONTENT));
	itemsLayout
			.measure(MeasureSpec.makeMeasureSpec(widthSize,
					MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(
					0, MeasureSpec.UNSPECIFIED));
	int width = itemsLayout.getMeasuredWidth();

	if (mode == MeasureSpec.EXACTLY) {
		width = widthSize;
	} else {
		width += 2 * PADDING;

		// Check against our minimum width
		width = Math.max(width, getSuggestedMinimumWidth());

		if (mode == MeasureSpec.AT_MOST && widthSize < width) {
			width = widthSize;
		}
	}

	itemsLayout.measure(MeasureSpec.makeMeasureSpec(width - 2 * PADDING,
			MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0,
			MeasureSpec.UNSPECIFIED));

	return width;
}
 
Example 26
@Override
protected View onCreateDialogView() {
	LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	LinearLayout layout = new LinearLayout(getContext());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6,6,6,6);
	
	TextView promptTextView = new TextView(getContext());
	promptTextView.setText(R.string.pressKey);
    promptTextView.setGravity(Gravity.CENTER_HORIZONTAL);
	
	valueTextView = new TextView(getContext());
	valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
    valueTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    valueTextView.setPadding(0, 12, 0, 12);
	
    TextView alertTextView = new TextView(getContext());
    alertTextView.setText(R.string.pressKeyInfo);
    alertTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    alertTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    
	layout.addView(promptTextView, params);
	layout.addView(valueTextView, params);
	layout.addView(alertTextView);
	
	return layout;
}
 
Example 27
Source Project: chappiecast   Source File: SystemWebChromeClient.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Override
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {            
        // Create a new Loading view programmatically.
        
        // create the linear layout
        LinearLayout layout = new LinearLayout(parentEngine.getView().getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(parentEngine.getView().getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);   
        layout.addView(bar);
        
        mVideoProgressView = layout;
    }
return mVideoProgressView; 
}
 
Example 28
Source Project: Android-HowOld   Source File: MyImageAdapter.java    License: MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

	ImageView imageView = new ImageView(context);
	imageView.setBackgroundResource(image[position % 13]);
	imageView.setLayoutParams(new Gallery.LayoutParams(400, 300));
	imageView.setScaleType(ScaleType.FIT_XY);

	return imageView;
}
 
Example 29
Source Project: 365browser   Source File: VrShellDelegate.java    License: Apache License 2.0 5 votes vote down vote up
private void setupVrModeWindowFlags() {
    if (mRestoreSystemUiVisibilityFlag == -1) {
        mRestoreSystemUiVisibilityFlag = mActivity.getWindow().getDecorView()
                .getSystemUiVisibility();
    }
    mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mActivity.getWindow().getDecorView().setSystemUiVisibility(VR_SYSTEM_UI_FLAGS);
}
 
Example 30
Source Project: FireFiles   Source File: AppRate.java    License: Apache License 2.0 5 votes vote down vote up
private void displayViews(ViewGroup mainView) {
    if(null != viewGroup){
        viewGroup.setVisibility(View.VISIBLE);
        viewGroup.addView(mainView);
    }
    else{
        LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        activity.addContentView(mainView, params);
    }

    Animation fadeInAnimation = AnimationUtils.loadAnimation(activity, android.R.anim.fade_in);
    mainView.startAnimation(fadeInAnimation);

    if (onShowListener != null) onShowListener.onRateAppShowing();
}