List of usage examples for android.view View View
public View(Context context)
From source file:im.ene.toro.exoplayer2.ExoVideoView.java
public ExoVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // By default, TextureView is used for Android 23 and below, and SurfaceView is for the rest boolean useTextureView = context.getResources().getBoolean(R.bool.use_texture_view); if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ExoVideoView, 0, 0); try {// ww w . j a v a 2 s.co m int surfaceType = a.getInt(R.styleable.ExoVideoView_tx2_surfaceType, SURFACE_TYPE_DEFAULT); switch (surfaceType) { case SURFACE_TYPE_SURFACE_VIEW: useTextureView = false; break; case SURFACE_TYPE_TEXTURE_VIEW: useTextureView = true; break; case SURFACE_TYPE_DEFAULT: default: // Unchanged, so don't need to execute the line below // useTextureView = context.getResources().getBoolean(R.bool.use_texture_view); break; } resizeMode = a.getInt(R.styleable.ExoVideoView_tx2_resizeMode, RESIZE_MODE_FIXED_WIDTH); } finally { a.recycle(); } } View view = useTextureView ? new TextureView(context) : new SurfaceView(context); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(params); surfaceView = view; addView(surfaceView, 0); shutterView = new View(context); ViewGroup.LayoutParams shutterViewParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); shutterView.setLayoutParams(shutterViewParams); shutterView.setBackgroundColor(Color.BLACK); addView(shutterView); window = new Timeline.Window(); componentListener = new ComponentListener(); mediaDataSourceFactory = buildDataSourceFactory(true); mainHandler = new Handler(); if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) { CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER); } requestFocus(); }
From source file:org.secuso.privacyfriendlydicegame.MainActivity.java
public View displayResults(int result, Button button) { hints(1);/* w w w . j av a 2 s. c om*/ View resultView = new View(getApplicationContext()); switch (result) { case 1: resultView = new DiceOne(getApplicationContext(), button, dotWidth); break; case 2: resultView = new DiceTwo(getApplicationContext(), button, dotWidth); break; case 3: resultView = new DiceThree(getApplicationContext(), button, dotWidth); break; case 4: resultView = new DiceFour(getApplicationContext(), button, dotWidth); break; case 5: resultView = new DiceFive(getApplicationContext(), button, dotWidth); break; case 6: resultView = new DiceSix(getApplicationContext(), button, dotWidth); break; default: break; } return resultView; }
From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java
private void addTableRowSpacer() { Context context = getActivity(); TableRow tableRow = new TableRow(context); View spacerView = new View(context); int spacerHeight = (int) (getResources().getDisplayMetrics().density * getResources().getDimension(R.dimen.network_info_spacer_height) + 0.5f); spacerView.setLayoutParams(new TableRow.LayoutParams(1, spacerHeight)); tableRow.addView(spacerView);/* www.j a va2 s .c o m*/ mNetworkInfoTableLayout.addView(tableRow); }
From source file:com.li.utils.ui.mdbottom.BottomNavigation.java
private void initialize(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) { typeface = new SoftReference<>(Typeface.DEFAULT); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.BottomNavigation, defStyleAttr, defStyleRes);//from w w w .jav a2 s. co m final int menuResId = array.getResourceId(R.styleable.BottomNavigation_bbn_entries, 0); pendingMenu = MenuParser.inflateMenu(context, menuResId); badgeProvider = parseBadgeProvider(this, context, array.getString(R.styleable.BottomNavigation_bbn_badgeProvider)); array.recycle(); backgroundColorAnimation = getResources().getInteger(R.integer.bbn_background_animation_duration); defaultSelectedIndex = 0; defaultHeight = getResources().getDimensionPixelSize(R.dimen.bbn_bottom_navigation_height); defaultWidth = getResources().getDimensionPixelSize(R.dimen.bbn_bottom_navigation_width); shadowHeight = getResources().getDimensionPixelOffset(R.dimen.bbn_top_shadow_height); // check if the bottom navigation is translucent // if (!isInEditMode()) { // final Activity activity = MiscUtils.getActivity(context); // if (null != activity) { // final SystemBarTintManager systembarTint = new SystemBarTintManager(activity); // if (MiscUtils.hasTranslucentNavigation(activity) // && systembarTint.getConfig().isNavigationAtBottom() // && systembarTint.getConfig().hasNavigtionBar()) { // bottomInset = systembarTint.getConfig().getNavigationBarHeight(); // } else { // bottomInset = 0; // } // topInset = systembarTint.getConfig().getStatusBarHeight(); // } // } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT); backgroundOverlay = new View(getContext()); backgroundOverlay.setLayoutParams(params); addView(backgroundOverlay); }
From source file:net.oschina.app.ui.MainActivity.java
private void initTabs() { MainTab[] tabs = MainTab.values();/*w ww.j a v a2s . c om*/ final int size = tabs.length; for (int i = 0; i < size; i++) { MainTab mainTab = tabs[i]; TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName())); View indicator = LayoutInflater.from(getApplicationContext()).inflate(R.layout.tab_indicator, null); TextView title = (TextView) indicator.findViewById(R.id.tab_title); Drawable drawable = this.getResources().getDrawable(mainTab.getResIcon()); title.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); if (i == 2) { indicator.setVisibility(View.INVISIBLE); mTabHost.setNoTabChangedTag(getString(mainTab.getResName())); } title.setText(getString(mainTab.getResName())); tab.setIndicator(indicator); tab.setContent(new TabContentFactory() { @Override public View createTabContent(String tag) { return new View(MainActivity.this); } }); mTabHost.addTab(tab, mainTab.getClz(), null); if (mainTab.equals(MainTab.ME)) { View cn = indicator.findViewById(R.id.tab_mes); mBvNotice = new BadgeView(MainActivity.this, cn); mBvNotice.setBadgePosition(BadgeView.POSITION_TOP_RIGHT); mBvNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); mBvNotice.setBackgroundResource(R.drawable.notification_bg); mBvNotice.setGravity(Gravity.CENTER); } mTabHost.getTabWidget().getChildAt(i).setOnTouchListener(this); } }
From source file:com.insthub.O2OMobile.Activity.F0_ProfileActivity.java
@Override public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException { if (url.endsWith(ApiInterface.USER_BALANCE)) { mBalance.setVisibility(View.VISIBLE); mBalance.setText("?" + Utils.formatBalance(mUserBalance.publicBalance) + ""); } else if (url.endsWith(ApiInterface.MYSERVICE_LIST)) { this.myServiceListJo = jo; if (mUserBalance.publicMyServiceList.size() > 0) { F0_ProfileServiceListAdapter listAdapteradapter = new F0_ProfileServiceListAdapter(this, mUserBalance.publicMyServiceList); mListview.setAdapter(listAdapteradapter); View foot = new View(this); foot.setLayoutParams(//from ww w . j av a2 s . c o m new AbsListView.LayoutParams(mListview.getMeasuredWidth(), ImageUtil.Dp2Px(this, 48))); mListview.addFooterView(foot); } } else if (url.endsWith(ApiInterface.USER_PROFILE)) { userprofileResponse response = new userprofileResponse(); response.fromJson(jo); mUser = response.user; mImageLoader.displayImage(mUser.avatar.thumb, mAvatar, O2OMobile.options_head); if (!mUser.nickname.equals("") && mUser.nickname != null) { mName.setText(mUser.nickname); } mCommentCount.setText(mUser.comment_count + ""); if (!mUser.comment_goodrate.equals("") && mUser.comment_goodrate != null) { mCommentGoodrate.setText((int) (Double.parseDouble(mUser.comment_goodrate) * 100) + "%"); } if (mUser.signature.equals("")) { mSignature.setText("??"); } else { mSignature.setText(mUser.signature); } if (mUser.id == SESSION.getInstance().uid) { if (mUser.user_group == ENUM_USER_GROUP.FREEMAN.value()) { mUserBalance.getServiceList(mUser.id); if (mUser.brief.equals("")) { mBirefLayout.setVisibility(View.GONE); } else { mBirefLayout.setVisibility(View.VISIBLE); mBrief.setText(mUser.brief); } } } else { if (mUser.brief.equals("")) { mBirefLayout.setVisibility(View.GONE); } else { mBirefLayout.setVisibility(View.VISIBLE); mBrief.setText(mUser.brief); } mUserBalance.getServiceList(mUserId); mHelp.setVisibility(View.VISIBLE); } if (mUser.my_certification.size() == 0) { mGridview.setVisibility(View.GONE); } else { mGridview.setVisibility(View.VISIBLE); F0_ProfileServiceListGridAdapter listAdapter = new F0_ProfileServiceListGridAdapter(this, mUser.my_certification); mGridviewServiceList.setAdapter(listAdapter); } } }
From source file:it.sephiroth.android.library.bottomnavigation.BottomNavigation.java
private void initialize(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) { typeface = new SoftReference<>(Typeface.DEFAULT); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.BottomNavigation, defStyleAttr, defStyleRes);// ww w . ja v a2 s . com final int menuResId = array.getResourceId(R.styleable.BottomNavigation_bbn_entries, 0); pendingMenu = MenuParser.inflateMenu(context, menuResId); badgeProvider = parseBadgeProvider(this, context, array.getString(R.styleable.BottomNavigation_bbn_badgeProvider)); array.recycle(); backgroundColorAnimation = getResources().getInteger(R.integer.bbn_background_animation_duration); defaultSelectedIndex = 0; defaultHeight = getResources().getDimensionPixelSize(R.dimen.bbn_bottom_navigation_height); defaultWidth = getResources().getDimensionPixelSize(R.dimen.bbn_bottom_navigation_width); shadowHeight = getResources().getDimensionPixelOffset(R.dimen.bbn_top_shadow_height); // check if the bottom navigation is translucent if (!isInEditMode()) { final Activity activity = MiscUtils.getActivity(context); if (null != activity) { final SystemBarTintManager systembarTint = new SystemBarTintManager(activity); if (MiscUtils.hasTranslucentNavigation(activity) && systembarTint.getConfig().isNavigationAtBottom() && systembarTint.getConfig().hasNavigtionBar()) { bottomInset = systembarTint.getConfig().getNavigationBarHeight(); } else { bottomInset = 0; } topInset = systembarTint.getConfig().getStatusBarHeight(); } } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT); backgroundOverlay = new View(getContext()); backgroundOverlay.setLayoutParams(params); addView(backgroundOverlay); }
From source file:org.openmrs.mobile.activities.addeditpatient.AddEditPatientFragment.java
@Override public void hideSoftKeys() { View view = this.getActivity().getCurrentFocus(); if (view == null) { view = new View(this.getActivity()); }/*from w w w . j a v a 2 s.c o m*/ InputMethodManager inputMethodManager = (InputMethodManager) this.getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:io.flutter.embedding.android.FlutterActivity.java
/** * Cover all visible {@code Activity} area with a {@code View} that paints everything the same * color as the {@code Window}./*from w w w. j a va2s . com*/ * <p> * This cover {@code View} should be displayed at the very beginning of the {@code Activity}'s * lifespan and then hidden once Flutter renders its first frame. The purpose of this cover is to * cover {@link FlutterSurfaceView}, which briefly displays a black rectangle before it can make * itself transparent. */ private void showCoverView() { if (getBackgroundMode() == BackgroundMode.transparent) { // Don't display an opaque cover view if the Activity is intended to be transparent. return; } // Create the coverView. if (coverView == null) { coverView = new View(this); addContentView(coverView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } // Pain the coverView with the Window's background. Drawable background = createCoverViewBackground(); if (background != null) { coverView.setBackground(background); } else { // If we can't obtain a window background to replicate then we'd be guessing as to the least // intrusive color. But there is no way to make an accurate guess. In this case we don't // give the coverView any color, which means a brief black rectangle will be visible upon // Activity launch. } }
From source file:cn.mailchat.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { //layout/*from ww w .j av a 2 s . c o m*/ RelativeLayout tabLayout = new RelativeLayout(getContext()); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tabLayout.setLayoutParams(layoutParams); RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textParams.addRule(RelativeLayout.CENTER_IN_PARENT); //tab TextView tab = new TextView(getContext()); tab.setId(100 + position); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tabLayout.addView(tab, textParams); //??? RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId()); viewParams.addRule(RelativeLayout.CENTER_VERTICAL); View view = new View(getContext()); ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(vParams); tabLayout.addView(view, viewParams); addTab(position, tabLayout); }