android.app.ActionBar.LayoutParams Java Examples

The following examples show how to use android.app.ActionBar.LayoutParams. 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: MainActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
public void doClick(View view) {
	//AlertDialog����
	// 1.����AlertDialog
	// AlertDialog dialog = new AlertDialog.Builder(this).setTitle("title")
	// .setMessage("message").create();
	// 2.ͨ��Dialog��ȡWindow
	// Window window = dialog.getWindow();
	// window.setGravity(Gravity.BOTTOM); // �˴���������dialog��ʾ��λ��
	// 3.��Window�������ö������
	// window.setWindowAnimations(R.style.dialogWindowAnim); // ��Ӷ���
	// ��ʾ�Ի���
	// dialog.show();
	
	//popupwindow�Ķ���
	View popupwindow = getLayoutInflater().inflate(
			R.layout.popupwindow_layout, null);
	PopupWindow pop = new PopupWindow(popupwindow,
			ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT);
	pop.setAnimationStyle(R.style.dialogWindowAnim);
	pop.showAsDropDown(view);
}
 
Example #2
Source File: SliderHelper.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
public SliderHelper(Activity activity) {
  slider = new Slider(activity);
  rangeSlider = new RangeSlider(activity);

  // Makes sure getParent() won't return null.
  container =
      new LinearLayout(activity) {
        @Override
        public boolean shouldDelayChildPressedState() {
          return simulateScrollableContainer;
        }
      };
  container.setPadding(50, 50, 50, 50);
  container.setOrientation(LinearLayout.VERTICAL);
  // Prevents getContentView() dead loop.
  container.setId(android.R.id.content);
  // Adds slider to layout, and adds layout to activity.
  container.addView(slider, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

  container.addView(rangeSlider, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
}
 
Example #3
Source File: SharePopWindow.java    From QiQuYing with Apache License 2.0 6 votes vote down vote up
@Override
  public void showAtLocation(View parent, int gravity, int x, int y) {
  	if(App.currentUser != null) {
	userId = App.currentUser.getId();
  	}
  	collect = collectDAO.getCollect(userId, mJoke.getId());
  	if(collect != null) {  //收藏过
  		getContentView().findViewById(R.id.share_collect).setSelected(true);
  	} else {
  		getContentView().findViewById(R.id.share_collect).setSelected(false);
  	}
  	Activity activity = ((Activity)context).getParent();
  	if(activity == null) {
  		activity = ((Activity)context);
  	}
  	WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
lp.alpha = 0.4f;
activity.getWindow().setAttributes(lp);
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
super.showAtLocation(parent, gravity, x, y);
  }
 
Example #4
Source File: BreadcrumbBarFragment.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if (tile != null) {
        ViewGroup vg = this.getActivity().findViewById(R.id.universal_frame_tile);
        //Check whether the view group is available. If so, this activity is a frame tile host 
        if (vg != null) {
            if (tile.getParent() != null) {
                ((ViewGroup)tile.getParent()).removeView(tile);
            }
            vg.addView(tile, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            //this doesn't really make it over well
            mInternalDetailView = null;
        }
    }
}
 
Example #5
Source File: ClockHandViewTouchTest.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Before
public void createClockFace() {
  ApplicationProvider.getApplicationContext().setTheme(R.style.Theme_MaterialComponents_Light);
  Activity activity = Robolectric.buildActivity(Activity.class).setup().start().get();
  clockHandView = new ClockHandView(activity);
  clockHandView.setCircleRadius(100);
  LinearLayout container = new LinearLayout(activity);
  container.setPadding(50, 50, 50, 50);
  container.setOrientation(LinearLayout.VERTICAL);
  container.setId(android.R.id.content);
  container.addView(clockHandView, new LayoutParams(300, 300));

  activity.setContentView(container);
}
 
Example #6
Source File: SharePopWindow.java    From QiQuYing with Apache License 2.0 5 votes vote down vote up
/**
   * 初始化窗口
   */
  private void initWindow() {
  	this.setClippingEnabled(false);
  	this.setWidth(LayoutParams.MATCH_PARENT);
      //设置弹出窗体的高
      this.setHeight(LayoutParams.WRAP_CONTENT);
      //设置弹出窗体可点击
      this.setFocusable(true);
      //设置弹出窗体动画效果
      this.setAnimationStyle(R.style.inoutformbottom);
      //实例化一个ColorDrawable颜色为半透明   (在此设置背景后此窗口不会出现黑色边框)
      ColorDrawable dw = new ColorDrawable(0xFFFFFFFF);
      //设置SelectPicPopupWindow弹出窗体的背景
      this.setBackgroundDrawable(dw);
      
//popupwindow消失的时候让窗口背景恢复
this.setOnDismissListener(new OnDismissListener() {
	@Override
	public void onDismiss() {
		Activity activity = ((Activity) context).getParent();
		if (activity == null) {
			activity = ((Activity) context);
		}
		WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
		lp.alpha = 1f;
		activity.getWindow().setAttributes(lp);
	}
});
  }
 
Example #7
Source File: CustomProgressDialog.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
public CustomProgressDialog(Context context, int resourceIdOfImage, String textToDisplay) {
		super(context, R.style.CustomProgressDialog);
		setTitle(null);
		setCancelable(false);
		setOnCancelListener(null);
		
		RelativeLayout layout = new RelativeLayout(context);
		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		params.addRule(RelativeLayout.CENTER_HORIZONTAL);
		
		rotatingImageView = new ImageView(context);
		rotatingImageView.setImageResource(resourceIdOfImage);
//		rotatingImageView.setId(1);
		
		layout.addView(rotatingImageView, params);
		
		textView = new TextView(context);
		textView.setText(textToDisplay);
		textView.setTextColor(context.getResources().getColor(R.color.white));
		
		params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		params.addRule(RelativeLayout.CENTER_HORIZONTAL);
		params.addRule(RelativeLayout.BELOW, rotatingImageView.getId());
		
		layout.addView(textView,params);
		
		addContentView(layout, params);
		
	}
 
Example #8
Source File: BreadcrumbBarFragment.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private void attachBreadcrumbBar(Activity activity, ActionBar actionBar) {
    //make sure we're in the right mode
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    //We need to get the amount that each item should "bleed" over to the left, and move the whole widget that
    //many pixels. This replicates the "overlap" space that each piece of the bar has on the next piece for
    //the left-most element.
    int buffer = Math.round(activity.getResources().getDimension(R.dimen.title_round_bleed));
    LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    p.leftMargin = buffer;

    activity.setTitle("");
    actionBar.setDisplayShowHomeEnabled(false);
}
 
Example #9
Source File: BreadcrumbBarFragment.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private View findAndLoadCaseTile(final Activity activity) {
    final View holder = LayoutInflater.from(activity).inflate(R.layout.com_tile_holder, null);
    final Pair<View, TreeReference> tileData = this.loadTile(activity);
    if (tileData == null || tileData.first == null) {
        return null;
    }

    View tile = tileData.first;
    final String inlineDetail = (String)tile.getTag();
    ((ViewGroup)holder.findViewById(R.id.com_tile_holder_frame)).addView(tile, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    ImageButton infoButton = holder.findViewById(R.id.com_tile_holder_btn_open);
    if (inlineDetail == null) {
        infoButton.setVisibility(View.GONE);
    }

    holder.setTag(INLINE_TILE_COLLAPSED);

    infoButton.setOnClickListener(v -> {
        boolean isCollapsed = INLINE_TILE_COLLAPSED.equals(holder.getTag());
        if (isCollapsed) {
            expandInlineTile(activity, holder, tileData, inlineDetail);
        } else {
            collapseTileIfExpanded(activity);
        }
    });
    return holder;
}
 
Example #10
Source File: DialtactsActivity.java    From coursera-android with MIT License 5 votes vote down vote up
private void prepareSearchView() {
    final View searchViewLayout =
            getLayoutInflater().inflate(R.layout.dialtacts_custom_action_bar, null);
    mSearchView = (SearchView) searchViewLayout.findViewById(R.id.search_view);
    mSearchView.setOnQueryTextListener(mPhoneSearchQueryTextListener);
    mSearchView.setOnCloseListener(mPhoneSearchCloseListener);
    // Since we're using a custom layout for showing SearchView instead of letting the
    // search menu icon do that job, we need to manually configure the View so it looks
    // "shown via search menu".
    // - it should be iconified by default
    // - it should not be iconified at this time
    // See also comments for onActionViewExpanded()/onActionViewCollapsed()
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setQueryHint(getString(R.string.hint_findContacts));
    mSearchView.setIconified(false);
    mSearchView.setOnQueryTextFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            if (hasFocus) {
                showInputMethod(view.findFocus());
            }
        }
    });

    if (!ViewConfiguration.get(this).hasPermanentMenuKey()) {
        // Filter option menu should be shown on the right side of SearchView.
        final View filterOptionView = searchViewLayout.findViewById(R.id.search_option);
        filterOptionView.setVisibility(View.VISIBLE);
        filterOptionView.setOnClickListener(mFilterOptionClickListener);
    }

    getActionBar().setCustomView(searchViewLayout,
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
 
Example #11
Source File: BlurActivity.java    From LiveBlurListView with Apache License 2.0 5 votes vote down vote up
private int canSetTranslucentFlag() {
	Resources resources = getResources();
	int id = resources.getIdentifier("config_enableTranslucentDecor", "bool", "android");
	if (id != 0) {
		boolean enabled = resources.getBoolean(id);
		if (enabled) {
			Window w = getWindow();  
			w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | 
   	        		WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, 
   	        		WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION |
   	        		WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
			
			//w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, 
			//WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

			id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
			if (id > 0) {
				if (!resources.getBoolean(id)) return 0;
			} else {
				return 0;
			}
   	        
			id = resources.getIdentifier("navigation_bar_height", "dimen", "android");
   	        
			if (id > 0) {
				return resources.getDimensionPixelSize(id);
			}
		}
	}
	return 0;
}
 
Example #12
Source File: TooltipWindow.java    From Twire with GNU General Public License v3.0 4 votes vote down vote up
public void showToolTip(View anchor, String tipText) {
    mTipText.setText(tipText);

    tipWindow.setHeight(LayoutParams.WRAP_CONTENT);
    tipWindow.setWidth(LayoutParams.WRAP_CONTENT);

    tipWindow.setOutsideTouchable(true);
    tipWindow.setTouchable(true);

    tipWindow.setBackgroundDrawable(new BitmapDrawable());

    tipWindow.setContentView(contentView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        tipWindow.setElevation(1f);
    }

    int[] screen_pos = new int[2];
    anchor.getLocationOnScreen(screen_pos);

    // Get rect for anchor view
    Rect anchor_rect = new Rect(screen_pos[0], screen_pos[1], screen_pos[0]
            + anchor.getWidth(), screen_pos[1] + anchor.getHeight());

    // Call view measure to calculate how big your view should be.
    contentView.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    int position_x = 0;
    int position_y = 0;
    if (position == POSITION_TO_RIGHT) {
        position_x = anchor_rect.right;
        position_y = (int) anchor.getY() + anchor.getHeight() / 2;
    } else if (position == POSITION_BOTTOM) {
        mNavUpArrow.setVisibility(View.VISIBLE);
        mNavLeftArrow.setVisibility(View.GONE);
        mTipText.forceLayout();

        position_x = anchor_rect.centerX() - (contentView.getMeasuredWidth() / 2);//anchor_rect.centerX() - (contentView.getWidth() / 2);
        position_y = anchor_rect.bottom - (anchor_rect.height() / 2);
    }

    tipWindow.showAtLocation(anchor, Gravity.NO_GRAVITY, position_x,
            position_y);


    contentView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
        revealTransition = ViewAnimationUtils.createCircularReveal(mainLayout, (int) mainLayout.getX(), (int) (mainLayout.getY() + mainLayout.getHeight() / 2), 0, mainLayout.getWidth());
        revealTransition.setInterpolator(new AccelerateDecelerateInterpolator());
        revealTransition.setDuration(REVEAL_DURATION);
        revealTransition.addListener(new SupportAnimator.AnimatorListener() {
            @Override
            public void onAnimationStart() {
                mainLayout.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd() {

            }

            @Override
            public void onAnimationCancel() {

            }

            @Override
            public void onAnimationRepeat() {

            }
        });
        revealTransition.start();
    });

    int HIDEDELAY = 1000 * 5;
    handler.sendEmptyMessageDelayed(MSG_DISMISS_TOOLTIP, HIDEDELAY);
}
 
Example #13
Source File: SliderHelper.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
void addContentView(Activity activity) {
  activity.addContentView(container, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
}