@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ffmpeg_preview); cancelBtn = (Button) findViewById(R.id.play_cancel); cancelBtn.setOnClickListener(this); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); surfaceView = (TextureView) findViewById(R.id.preview_video); RelativeLayout previewVideoParent = (RelativeLayout)findViewById(R.id.preview_video_parent); LayoutParams layoutParams = (LayoutParams) previewVideoParent .getLayoutParams(); layoutParams.width = displaymetrics.widthPixels; layoutParams.height = displaymetrics.widthPixels; previewVideoParent.setLayoutParams(layoutParams); surfaceView.setSurfaceTextureListener(this); surfaceView.setOnClickListener(this); path = getIntent().getStringExtra("path"); imagePlay = (ImageView) findViewById(R.id.previre_play); imagePlay.setOnClickListener(this); mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); }
@Override public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout layoutView = new RelativeLayout(context); TextView textView = new TextView(context); textView.setTextSize(13); textView.setText(itemList.get(position)); textView.setTag(position); if (checkedPosition == position || itemList.size() == 1) { // layoutView.setBackgroundColor(0x8033B5E5); textView.setTextColor(context.getResources().getColor(R.color.rb_text_check)); } else { textView.setTextColor(Color.WHITE); } LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT); layoutView.addView(textView, params); layoutView.setMinimumHeight(ParamsUtil.dpToPx(context, 26)); return layoutView; }
public PopMenu(Context context, int resid, int checkedPosition, int height) { this.context = context; this.checkedPosition = checkedPosition; itemList = new ArrayList<String>(); RelativeLayout view = new RelativeLayout(context); // view.setBackgroundResource(resid); listView = new ListView(context); listView.setPadding(0, ParamsUtil.dpToPx(context, 3), 0, ParamsUtil.dpToPx(context, 3)); view.addView(listView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); listView.setAdapter(new PopAdapter()); listView.setOnItemClickListener(this); popupWindow = new PopupWindow(view, context.getResources().getDimensionPixelSize(R.dimen.popmenu_width), height); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(178, 0, 0, 0))); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); service = new Intent(this, UploadService.class); inputLayout = new RelativeLayout(this); inputLayout.setBackgroundColor(Color.WHITE); inputLayout.setHorizontalGravity(Gravity.CENTER_HORIZONTAL); inputLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); getCategory(); initView(); bindService(service, serviceConnection, Context.BIND_AUTO_CREATE); String path = getIntent().getStringExtra("filePath"); if (path != null) { filePath = path; } getActionBar().setDisplayHomeAsUpEnabled(true); uploadButton.setOnClickListener(this); setContentView(inputLayout); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { activity = getActivity(); context = activity.getApplicationContext(); RelativeLayout downloadLayout = new RelativeLayout(activity.getApplicationContext()); downloadLayout.setBackgroundColor(Color.WHITE); receiver = new DownloadedReceiver(); activity.registerReceiver(receiver, new IntentFilter(ConfigUtil.ACTION_DOWNLOADED)); downloadedListView = new ListView(context); downloadedListView.setPadding(10, 10, 10, 10); downloadedListView.setDivider(getResources().getDrawable(R.drawable.line)); LayoutParams downloadedLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); downloadLayout.addView(downloadedListView, downloadedLayoutParams); initData(); downloadedListView.setOnItemClickListener(onItemClickListener); downloadedListView.setOnCreateContextMenuListener(onCreateContextMenuListener); return downloadLayout; }
private void init(Context context, AttributeSet attrs) { try { this.mJarClassLoader = JarLoader.getJarClassLoader(context, "Letv_Ads.apk", JarConstant.LETV_ADS_PACKAGENAME); this.mJarResources = JarResources.getResourceByCl(this.mJarClassLoader, context); mLoadClass = JarLoader.loadClass(context, "Letv_Ads.apk", JarConstant.LETV_ADS_PACKAGENAME, JarConstant.LETV_ADS_VIEW_CLASS); Constructor<?> localConstructor = mLoadClass.getConstructor(new Class[]{Context.class, AttributeSet.class, Resources.class}); if (this.mJarResources != null) { updateConfiguration(this.mJarResources.getResources()); this.mRemoteView = (RelativeLayout) localConstructor.newInstance(new Object[]{context, attrs, this.mJarResources.getResources()}); } } catch (Exception e) { e.printStackTrace(); LogInfo.log(TAG, "Exception e=" + e.toString()); } if (this.mRemoteView != null) { LogInfo.log(TAG, "addView mRemoteView=" + this.mRemoteView); addView(this.mRemoteView, new LayoutParams(-1, -1)); } }
protected void showDeleteLayout() { if (getActivity() != null && this.mHeaderLayout != null) { LayoutParams params = (LayoutParams) this.mPullListView.getLayoutParams(); if (!this.mIsDelete || this.mListAdapter == null || this.mListAdapter.getCount() <= 0) { params.bottomMargin = 0; this.mHeaderLayout.setVisibility(8); upDateLogin(); return; } this.mHeaderLayout.setVisibility(0); if (this.mHeaderLayout.getHeight() == 0) { params.bottomMargin = ((UIs.zoomRealHeight(50) * 3) / 4) + 1; } else { params.bottomMargin = this.mHeaderLayout.getHeight(); } this.mPullListView.setLayoutParams(params); } }
@Override protected View onCreateDialogView() { RelativeLayout relativeLayout = new RelativeLayout(getContext()); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); layoutParams.addRule(RelativeLayout.BELOW, 2); LayoutParams layoutParamsText = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParamsText.addRule(RelativeLayout.ALIGN_PARENT_TOP); layoutParamsText.addRule(RelativeLayout.CENTER_HORIZONTAL); colorPickerView = new ColorPicker(getContext()); colorPickerView.setId(1); currentColor = new TextView(getContext()); currentColor.setTextSize(16); currentColor.setId(2); relativeLayout.addView(colorPickerView, layoutParams); relativeLayout.addView(currentColor, layoutParamsText); return relativeLayout; }
protected void addTab(int index, CharSequence text, int iconResId) { TabView tabView = new TabView(this, getContext(), text); tabView.setIndex(index); tabView.setFocusable(true); tabView.setOnClickListener(this.mTabClickListener); if (iconResId != 0) { tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0); } int width = this.mMeanWidth == -1 ? getTabWidth(text) : this.mMeanWidth; if (this.mMeanWidth != -1) { tabView.setSize(this.mMeanWidth, UIsUtils.dipToPx(38.0f)); } else { tabView.setSize(width, UIsUtils.dipToPx(38.0f)); } RelativeLayout relativeLayout = new RelativeLayout(this.mContext); relativeLayout.setGravity(17); relativeLayout.setLayoutParams(new LayoutParams(-2, UIsUtils.dipToPx(38.0f))); LayoutParams params = new LayoutParams(-2, UIsUtils.dipToPx(38.0f)); params.setMargins(TAB_MARGIN, 0, TAB_MARGIN, 0); tabView.setLayoutParams(params); relativeLayout.addView(tabView); if (this.mIsHome) { ThemeDataManager.getInstance(this.mContext).setContentTheme(tabView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR); } ImageView imageView = new ImageView(this.mContext); LayoutParams imageViewParams = new LayoutParams(width, UIsUtils.dipToPx(2.0f)); imageViewParams.setMargins(TAB_MARGIN, UIsUtils.dipToPx(36.0f), TAB_MARGIN, 0); imageView.setLayoutParams(imageViewParams); relativeLayout.addView(imageView); imageView.setBackgroundDrawable(getResources().getDrawable(2130838177)); if (this.mIsHome) { ThemeDataManager.getInstance(this.mContext).setShapeSelectorViewTheme(imageView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR, 2, true); } this.mTabLayout.addView(relativeLayout); }
@Override public void onGlobalLayout() { Rect r = new Rect(); baseRoot.getGlobalVisibleRect(r); // 进入Activity时会布局,第一次调用onGlobalLayout,先记录开始软键盘没有弹出时底部的位置 if (rootBottom == Integer.MIN_VALUE) { rootBottom = r.bottom; return; } // adjustResize,软键盘弹出后高度会变小 if (r.bottom < rootBottom) { //按照键盘高度设置表情框和发送图片按钮框的高度 keyboardHeight = rootBottom - r.bottom; SystemConfigSp.instance().init(MessageActivity.this); SystemConfigSp.instance().setIntConfig(currentInputMethod, keyboardHeight); LayoutParams params = (LayoutParams) addOthersPanelView.getLayoutParams(); params.height = keyboardHeight; LayoutParams params1 = (LayoutParams) emoLayout.getLayoutParams(); params1.height = keyboardHeight; } }
private void initWebView() { if (this.mWebView == null) { this.mWebView = new WebView(this); this.mWebView.setBackgroundColor(-1); this.rootView.addView(this.mWebView, new LayoutParams(-1, -1)); this.mWebView.getSettings().setUseWideViewPort(true); this.mWebView.getSettings().setSupportZoom(true); this.mWebView.getSettings().setBuiltInZoomControls(true); this.mWebView.setVerticalScrollBarEnabled(true); this.mWebView.setHorizontalScrollBarEnabled(true); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.getSettings().setDomStorageEnabled(true); this.mWebView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { AlbumPlayActivity.this.mWebView.loadUrl(url); return super.shouldOverrideUrlLoading(view, url); } }); this.mWebView.setClickable(false); } }
private ImageView addMirrorView(ViewGroup parent, RecyclerView recyclerView, View view) { view.destroyDrawingCache(); view.setDrawingCacheEnabled(true); ImageView mirrorView = new ImageView(recyclerView.getContext()); Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); mirrorView.setImageBitmap(bitmap); view.setDrawingCacheEnabled(false); int[] locations = new int[2]; view.getLocationOnScreen(locations); int[] parenLocations = new int[2]; recyclerView.getLocationOnScreen(parenLocations); LayoutParams params = new LayoutParams(bitmap.getWidth(), bitmap.getHeight()); params.setMargins(locations[0], (locations[1] - parenLocations[1]) + UIsUtils.dipToPx(44.0f), 0, 0); parent.addView(mirrorView, params); return mirrorView; }
private void initNavigationBar() { RelativeLayout my_playrecrod_content = (RelativeLayout) findViewById(R.id.my_collect_content); LayoutParams params = (LayoutParams) my_playrecrod_content.getLayoutParams(); params.bottomMargin = 0; my_playrecrod_content.setLayoutParams(params); this.mBackImageView = (ImageView) findViewById(2131362351); this.mEditView = (TextView) findViewById(2131362354); this.mEditView.setText(2131099788); this.mEditView.setTextColor(this.mContext.getResources().getColor(2131493261)); this.mTitleView = (TextView) findViewById(2131362352); this.mLoginTip = (RelativeLayout) findViewById(R.id.my_collect_bottom_login_btn); this.mLoginTip.setVisibility(8); this.mTitleView.setText(getResources().getString(2131100479)); this.mBackImageView.setOnClickListener(this.onClickEvent); this.mTitleView.setOnClickListener(this.onClickEvent); this.mEditView.setOnClickListener(this.onClickEvent); }
private void initHeaderView() { this.mHeaderView = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.view_live_header, null); this.mViewpager = (ViewPager) this.mHeaderView.findViewById(R.id.view_live_header_viewpager); this.mRecyclerview = (RecyclerView) this.mHeaderView.findViewById(R.id.view_live_header_recyclerview); this.mIvSingle = (ImageView) this.mHeaderView.findViewById(R.id.view_live_header_iv_single); this.mIvDouble = (ImageView) this.mHeaderView.findViewById(R.id.view_live_header_iv_double); this.mHeaderView.setClipChildren(false); int width = UIsUtils.getScreenWidth() - UIsUtils.dipToPx(40.0f); this.mViewPagerHeight = (width * 240) / 320; LayoutParams params = (LayoutParams) this.mViewpager.getLayoutParams(); params.width = width; params.height = this.mViewPagerHeight; this.mViewpager.setLayoutParams(params); initHeaderImageView(); initViewPager(); initRecyclerView(); this.mListView.addHeaderView(this.mHeaderView); }
private void initBarrageLayout() { this.mBarrageContainId = GenerateViewId.generateViewId(); LayoutParams params = new LayoutParams(-1, -1); View view = LayoutInflater.from(this.mContext).inflate(R.layout.live_barrage_contain, null); view.setId(this.mBarrageContainId); addView(view, params); }
private void qualityShow(boolean show) { this.qualityShowing = show; this.mTVSpreadLayout.setVisibility(4); if (show) { int[] locations = new int[2]; this.mQuality.getLocationInWindow(locations); int x = locations[0]; this.mBottomBar.getLocationOnScreen(locations); int y = locations[1]; LayoutParams params = (LayoutParams) this.mQualityLayout.getLayoutParams(); params.leftMargin = (((this.mQuality.getMeasuredWidth() >> 1) + x) - (this.mLevelBtnLayout.getMeasuredWidth() >> 1)) - this.mTVSpreadLayout.getMeasuredWidth(); params.topMargin = (y - this.mQualityLayout.getMeasuredHeight()) - 10; this.mQualityLayout.setLayoutParams(params); this.mQualityLayout.requestLayout(); this.mQualityLayout.setVisibility(0); this.mQuality.setBackgroundResource(2130837620); return; } this.mQualityLayout.setVisibility(8); this.mQuality.setBackgroundResource(2130837742); this.is4KClick = false; this.is1080pClick = false; }
private void createViews() { this.mFlMain = new com.tencent.open.c.a((Context) this.mWeakContext.get()); this.mFlMain.setBackgroundColor(1711276032); this.mFlMain.setLayoutParams(new LayoutParams(-1, -1)); this.mWebView = new b((Context) this.mWeakContext.get()); this.mWebView.setBackgroundColor(0); this.mWebView.setBackgroundDrawable(null); if (VERSION.SDK_INT >= 11) { try { View.class.getMethod("setLayerType", new Class[]{Integer.TYPE, Paint.class}).invoke(this.mWebView, new Object[]{Integer.valueOf(1), new Paint()}); } catch (Exception e) { e.printStackTrace(); } } ViewGroup.LayoutParams layoutParams = new LayoutParams(-1, this.mWebviewHeight); layoutParams.addRule(13, -1); this.mWebView.setLayoutParams(layoutParams); this.mFlMain.addView(this.mWebView); this.mFlMain.a(this); setContentView(this.mFlMain); }
/** * Toggles button location on click between top-left and bottom-right */ private void moveButton() { LayoutParams params = (LayoutParams) mButton.getLayoutParams(); if (mTopLeft) { params.removeRule(RelativeLayout.ALIGN_PARENT_LEFT); params.removeRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); } else { params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); } mButton.setLayoutParams(params); mTopLeft = !mTopLeft; }
@Override public void doOnViewCreated(View v, @Nullable Bundle savedInstanceState) { statusCircle = v.findViewById(R.id.statusCircle); statusHint = (OneSheeldTextView) v.findViewById(R.id.statusHint); rmsIndicator = (TextView) v.findViewById(R.id.rmsLevelIndicator); recognizedResult = (OneSheeldTextView) v .findViewById(R.id.recognizedResult); params = (LayoutParams) rmsIndicator.getLayoutParams(); statusCircle.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (stepValue == 0) stepValue = statusCircle.getHeight() / 10; } }); }
@Override public void doOnViewCreated(View v, @Nullable Bundle savedInstanceState) { soundLevelIndicator = (TextView) v .findViewById(R.id.soundLevelIndicator); micValue = (OneSheeldTextView) v.findViewById(R.id.micValue); micState = (OneSheeldTextView) v.findViewById(R.id.micState); params = (LayoutParams) soundLevelIndicator.getLayoutParams(); soundLevelIndicator.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { stepValue = soundLevelIndicator.getHeight() / 80; } }); }
private void createViews() { this.mFlMain = new com.tencent.open.c.a((Context) this.mWeakContext.get()); this.mFlMain.setBackgroundColor(1711276032); this.mFlMain.setLayoutParams(new LayoutParams(-1, -1)); this.mWebView = new b((Context) this.mWeakContext.get()); this.mWebView.setBackgroundColor(0); this.mWebView.setBackgroundDrawable(null); if (VERSION.SDK_INT >= 11) { try { View.class.getMethod("setLayerType", new Class[]{Integer.TYPE, Paint.class}) .invoke(this.mWebView, new Object[]{Integer.valueOf(1), new Paint()}); } catch (Exception e) { e.printStackTrace(); } } ViewGroup.LayoutParams layoutParams = new LayoutParams(-1, this.mWebviewHeight); layoutParams.addRule(13, -1); this.mWebView.setLayoutParams(layoutParams); this.mFlMain.addView(this.mWebView); this.mFlMain.a(this); setContentView(this.mFlMain); }
public ProgressWebView(Activity activity) { super(activity); this.g = activity; this.d = new ProgressBar(activity, null, 16842872); this.d.setLayoutParams(new LayoutParams(-1, o.a(activity, 5.0f))); addView(this.d); setDownloadListener(new p(this)); setWebChromeClient(new t(this)); setWebViewClient(new q(this)); getSettings().setJavaScriptEnabled(true); getSettings().setUseWideViewPort(true); getSettings().setDomStorageEnabled(true); getSettings().setLoadWithOverviewMode(true); getSettings().setBuiltInZoomControls(false); getSettings().setUserAgentString(a(new StringBuilder(this.i))); }
private RelativeLayout getPageView() { this.rlPage = new RelativeLayout(getContext()); this.rlPage.setBackgroundDrawable(this.background); if (this.dialogMode) { RelativeLayout rlDialog = new RelativeLayout(getContext()); rlDialog.setBackgroundColor(-1070452174); int dp_8 = R.dipToPx(getContext(), 8); LayoutParams lpDialog = new LayoutParams(R.getScreenWidth(getContext()) - (dp_8 * 2), -2); lpDialog.topMargin = dp_8; lpDialog.bottomMargin = dp_8; lpDialog.addRule(13); rlDialog.setLayoutParams(lpDialog); this.rlPage.addView(rlDialog); rlDialog.addView(getPageTitle()); rlDialog.addView(getPageBody()); rlDialog.addView(getImagePin()); } else { this.rlPage.addView(getPageTitle()); this.rlPage.addView(getPageBody()); this.rlPage.addView(getImagePin()); } return this.rlPage; }
private TitleLayout getPageTitle() { this.llTitle = new TitleLayout(getContext()); this.llTitle.setId(1); this.llTitle.getBtnBack().setOnClickListener(this); int resId = R.getStringRes(this.activity, "multi_share"); if (resId > 0) { this.llTitle.getTvTitle().setText(resId); } this.llTitle.getBtnRight().setVisibility(0); resId = R.getStringRes(this.activity, "share"); if (resId > 0) { this.llTitle.getBtnRight().setText(resId); } this.llTitle.getBtnRight().setOnClickListener(this); LayoutParams lp = new LayoutParams(-2, -2); lp.addRule(9); lp.addRule(10); lp.addRule(11); this.llTitle.setLayoutParams(lp); return this.llTitle; }
private LinearLayout getPageBody() { this.llBody = new LinearLayout(getContext()); this.llBody.setId(2); int resId = R.getBitmapRes(this.activity, "edittext_back"); if (resId > 0) { this.llBody.setBackgroundResource(resId); } this.llBody.setOrientation(1); LayoutParams lpBody = new LayoutParams(-2, -2); lpBody.addRule(5, this.llTitle.getId()); lpBody.addRule(3, this.llTitle.getId()); lpBody.addRule(7, this.llTitle.getId()); if (!this.dialogMode) { lpBody.addRule(12); } int dp_3 = R.dipToPx(getContext(), 3); lpBody.setMargins(dp_3, dp_3, dp_3, dp_3); this.llBody.setLayoutParams(lpBody); this.llBody.addView(getMainBody()); this.llBody.addView(getSep()); this.llBody.addView(getPlatformList()); return this.llBody; }
private LinearLayout getMainBody() { LinearLayout llMainBody = new LinearLayout(getContext()); llMainBody.setOrientation(1); LinearLayout.LayoutParams lpMain = new LinearLayout.LayoutParams(-1, -2); lpMain.weight = 1.0f; int dp_4 = R.dipToPx(getContext(), 4); lpMain.setMargins(dp_4, dp_4, dp_4, dp_4); llMainBody.setLayoutParams(lpMain); LinearLayout llContent = new LinearLayout(getContext()); LinearLayout.LayoutParams lpContent = new LinearLayout.LayoutParams(-1, -2); lpContent.weight = 1.0f; llMainBody.addView(llContent, lpContent); this.etContent = new EditText(getContext()); this.etContent.setGravity(51); this.etContent.setBackgroundDrawable(null); this.etContent.setText(String.valueOf(this.shareParamMap.get("text"))); this.etContent.addTextChangedListener(this); LinearLayout.LayoutParams lpEt = new LinearLayout.LayoutParams(-2, -2); lpEt.weight = 1.0f; this.etContent.setLayoutParams(lpEt); llContent.addView(this.etContent); llContent.addView(getThumbView()); llMainBody.addView(getBodyBottom()); return llMainBody; }
public PlayChangeVideoPopupWindow(Context context, int height) { this.context = context; RelativeLayout view = new RelativeLayout(context); listView = new ListView(context); listView.setPadding(0, ParamsUtil.dpToPx(context, 3), 0, ParamsUtil.dpToPx(context, 3)); view.addView(listView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); adapter = new VideosAdapter(); listView.setAdapter(adapter); popupWindow = new PopupWindow(view, height * 2 / 3 , height); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(178, 0, 0, 0))); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { activity = getActivity(); context = activity.getApplicationContext(); receiver = new UploadReceiver(); activity.registerReceiver(receiver, new IntentFilter(ConfigUtil.ACTION_UPLOAD)); service = new Intent(context, UploadService.class); binderService(); RelativeLayout view = new RelativeLayout(context); view.setBackgroundColor(Color.WHITE); LayoutParams uploadLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); uploadListView = new ListView(context); uploadListView.setDivider(getResources().getDrawable(R.drawable.line)); view.addView(uploadListView, uploadLayoutParams); uploadListView.setOnItemClickListener(onItemClickListener); uploadListView.setOnCreateContextMenuListener(onCreateContextMenuListener); initUploadList(); LayoutParams uploadButtonLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); uploadButtonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); uploadButtonLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); uploadButton = new Button(context); view.addView(uploadButton, uploadButtonLayoutParams); uploadButton.setText("上传"); uploadButton.setTextColor(0xFFFFFFFF); uploadButton.setOnClickListener(uploadOnClickListener); timer.schedule(timerTask, 0, 1000); return view; }
@Override protected void onCreate(Bundle savedInstanceState) { getActionBar().setDisplayHomeAsUpEnabled(true); RelativeLayout accountLayout = new RelativeLayout(this); accountLayout.setBackgroundColor(Color.WHITE); LayoutParams accountLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); accountLayout.setLayoutParams(accountLayoutParams); ListView accountListView = new ListView(this); accountListView.setPadding(10, 10, 10, 10); accountListView.setDivider(getResources().getDrawable(R.drawable.line)); LayoutParams accountListViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); accountLayout.addView(accountListView, accountListViewParams); List<Pair<String, String>> pairs = new ArrayList<Pair<String,String>>(); Pair<String, String> userIdPair = new Pair<String, String>("User ID",ConfigUtil.USERID); pairs.add(userIdPair); Pair<String, String> apiKeyPair = new Pair<String, String>("API Key", ConfigUtil.API_KEY); pairs.add(apiKeyPair); AccountViewAdapter accountViewAdapter = new AccountViewAdapter(this, pairs); accountListView.setAdapter(accountViewAdapter); setContentView(accountLayout); super.onCreate(savedInstanceState); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { activity = getActivity(); context = activity.getApplicationContext(); receiver = new DownloadedReceiver(); activity.registerReceiver(receiver, new IntentFilter(ConfigUtil.ACTION_DOWNLOADING)); RelativeLayout downloadRelativeLayout = new RelativeLayout(context); downloadRelativeLayout.setBackgroundColor(Color.WHITE); downloadRelativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); downloadListView = new ListView(context); downloadListView.setPadding(10, 10, 10, 10); downloadListView.setDivider(getResources().getDrawable(R.drawable.line)); LayoutParams listViewLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); downloadRelativeLayout.addView(downloadListView, listViewLayout); // 生成动态数组,加入数据 pairs = new ArrayList<Pair<String,Integer>>(); for (int i = 0; i < downloadVideoIds.length; i++) { Pair<String, Integer> pair = new Pair<String, Integer>(downloadVideoIds[i], R.drawable.download); pairs.add(pair); } downloadListViewAdapter = new DownloadListViewAdapter(context, pairs); downloadListView.setAdapter(downloadListViewAdapter); downloadListView.setOnItemClickListener(onItemClickListener); service = new Intent(context, DownloadService.class); activity.bindService(service, serviceConnection, Context.BIND_AUTO_CREATE); initDownloaderHashMap(); return downloadRelativeLayout; }
private void initView(RelativeLayout view ){ view.setBackgroundColor(Color.WHITE); LayoutParams downloadingLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); downloadingListView = new ListView(context); downloadingListView.setPadding(10, 10, 10, 10); downloadingListView.setDivider(getResources().getDrawable(R.drawable.line)); view.addView(downloadingListView, downloadingLayoutParams); downloadingListView.setOnItemClickListener(onItemClickListener); downloadingListView.setOnCreateContextMenuListener(onCreateContextMenuListener); }
private View getItemView(Pair<String, String> pair){ RelativeLayout accountView = new RelativeLayout(context); TextView textView = new TextView(context); textView.setText(pair.first + " : " + pair.second); textView.setTextSize(16); textView.setPadding(10, 30, 0, 0); textView.setMinHeight(ParamsUtil.dpToPx(context, 48)); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_VERTICAL); accountView.addView(textView, params); return accountView; }
public static void resizeAdView(Activity activity, WindowManager wm, final ImageView iv, int adWidth, int adHeight) { if (adWidth == 0 || adHeight == 0) { return; } int screenWidth = wm.getDefaultDisplay().getWidth(); int screenHeight = wm.getDefaultDisplay().getHeight(); if (PlayerUtil.isPortrait()) { screenHeight = screenHeight * 2 / 5; } else { // 全屏下,广告素材为屏幕60% screenWidth = screenWidth * 6 / 10; screenHeight = screenHeight * 6 / 10; } // 等比缩放比例计算 float widthRatio = (float) screenWidth / (float) adWidth; float heightRatio = (float) screenHeight / (float) adHeight; if (widthRatio > heightRatio) { screenWidth = (int) ((float) adWidth * heightRatio); } else { screenHeight = (int) ((float) adHeight * widthRatio); } final LayoutParams ivAdLayoutParams = new LayoutParams(screenWidth, screenHeight); ivAdLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); activity.runOnUiThread(new Runnable() { @Override public void run() { iv.setLayoutParams(ivAdLayoutParams); } }); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getActivity().getApplicationContext(); RelativeLayout playLayout = new RelativeLayout(context); playLayout.setBackgroundColor(Color.WHITE); LayoutParams playLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); playLayout.setLayoutParams(playLayoutParams); playListView = new ListView(context); playListView.setDivider(getResources().getDrawable(R.drawable.line)); playListView.setDividerHeight(2); playListView.setPadding(10, 10, 10, 10); LayoutParams playListLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); playLayout.addView(playListView, playListLayoutParams); // 生成动态数组,加入数据 pairs = new ArrayList<Pair<String,Integer>>(); for (int i = 0; i < playVideoIds.length; i++) { Pair<String, Integer> pair = new Pair<String, Integer>(playVideoIds[i], R.drawable.play); pairs.add(pair); } videoListViewAdapter = new VideoListViewAdapter(context, pairs); playListView.setAdapter(videoListViewAdapter); playListView.setOnItemClickListener(onItemClickListener); return playLayout; }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (isPrepared) { // 刷新界面 setLayoutVisibility(View.GONE, false); setLayoutVisibility(View.VISIBLE, true); } lockView.setSelected(false); if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); rlBelow.setVisibility(View.VISIBLE); ivFullscreen.setImageResource(R.drawable.fullscreen_close); if (playChangeVideoPopupWindow != null) { playChangeVideoPopupWindow.dismiss(); } if (playTopPopupWindow != null) { playTopPopupWindow.dismiss(); } } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); rlBelow.setVisibility(View.GONE); ivFullscreen.setImageResource(R.drawable.fullscreen_open); } setSurfaceViewLayout(); }
private void setSurfaceSize() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int width = metrics.widthPixels; int height = (int) (width * PREVIEW_WIDTH / (float)PREVIEW_HEIGHT); RelativeLayout.LayoutParams params = new LayoutParams(width, height); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); mPreviewSurface.setLayoutParams(params); mFaceSurface.setLayoutParams(params); }
private void createListenerView() { this.listenerView = new View(this.context) { protected boolean fitSystemWindows(Rect insets) { if (insets.top == 0) { InboxViewManager.this.logger.info("fitSystemWindows : 0"); InboxViewManager.this.setTabVisibility(Boolean.valueOf(false), eVisibilityReason.FullScreenMode); } else { InboxViewManager.this.logger.info("fitSystemWindows : != 0"); InboxViewManager.this.setTabVisibility(Boolean.valueOf(true), eVisibilityReason.FullScreenMode); } return super.fitSystemWindows(insets); } public boolean dispatchKeyEvent(KeyEvent event) { if (event.getKeyCode() == 4) { } return super.dispatchKeyEvent(event); } }; this.listenerView.setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() { public void onSystemUiVisibilityChange(int visibility) { if ((visibility & 4) == 0) { InboxViewManager.this.setTabVisibility(Boolean.valueOf(true), eVisibilityReason.FullScreenMode); } else { InboxViewManager.this.setTabVisibility(Boolean.valueOf(false), eVisibilityReason.FullScreenMode); } } }); WindowManager.LayoutParams params = new WindowManager.LayoutParams(-2, -2, 2002, 65816, -3); params.width = 1; params.height = 1; params.gravity = 51; getWindowManager().addView(this.listenerView, params); }
private void initSoftInputMethod() { this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); receiver = new switchInputMethodReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction("android.intent.action.INPUT_METHOD_CHANGED"); registerReceiver(receiver, filter); SystemConfigSp.instance().init(this); currentInputMethod = Settings.Secure.getString(MessageActivity.this.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); keyboardHeight = SystemConfigSp.instance().getIntConfig(currentInputMethod); }
private void upDateLogin() { LayoutParams params = (LayoutParams) this.mPullListView.getLayoutParams(); if (this.mIsLogin) { this.mBottomLogin.setVisibility(8); params.bottomMargin = 0; } else { this.mBottomLogin.setVisibility(0); params.bottomMargin = this.mBottomLogin.getHeight(); } this.mPullListView.setLayoutParams(params); }