List of usage examples for android.widget RelativeLayout addView
public void addView(View child)
Adds a child view.
From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java
/** * this function will initialize the ui showing the current image and reload * everything to make sure it is shown correctly *///from w ww. j a v a 2s . c o m private void initUI() { // set the actionBar title and subtitle if (actionBar != null) { actionBar.setTitle(R.string.send_image); actionBar.setSubtitle(name); // actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor // (R.color.action_bar_transparent))); // // set the statusBar color // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) // getActivity().getWindow().setStatusBarColor(getResources().getColor(R // .color.action_bar_transparent)); } // instantiate the ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.send_image_view_pager); viewPager.setAdapter(new MyPagerAdapter()); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { changePage(position, false, false); } @Override public void onPageScrollStateChanged(int state) { } }); //Cancel button pressed getView().findViewById(R.id.send_image_cancel).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // just return to the chatFragment mListener.onReturnClick(); } }); //Send button pressed getView().findViewById(R.id.send_image_send).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // create the progressDialog that is to be shown while saving // the image ProgressDialog progressDialog = new ProgressDialog(getContext()); if (images.size() > 1) progressDialog.setTitle( String.format(getResources().getString(R.string.sending_images), images.size())); else progressDialog.setTitle(R.string.sending_image); // run the sendImage in a new thread because I am saving the // image and this should be done in a new thread new Thread(new SendImagesRunnable(new Handler(), getContext(), progressDialog)).start(); } }); // generate the overview only if there are at least 2 images if (images.size() > 1) { // the layoutParams for the imageView which has the following attributes: // width = height = 65dp // margin = 5dp getActivity().findViewById(R.id.send_image_overview).setVisibility(View.VISIBLE); int a = Constants.dipToPixel(getContext(), 65); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(a, a); int b = Constants.dipToPixel(getContext(), 5); imageViewParams.setMargins(b, b, b, b); // the layoutParams for the backgroundView which has the following // attributes: // width = height = 71dp // margin = 2dp int c = Constants.dipToPixel(getContext(), 71); RelativeLayout.LayoutParams backgroundParams = new RelativeLayout.LayoutParams(c, c); int d = Constants.dipToPixel(getContext(), 2); backgroundParams.setMargins(d, d, d, d); // the layoutParams for the relativeLayout containing the image and // the background which has the following attributes: // width = height = wrap_content LinearLayout.LayoutParams relativeLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout linearLayout = (LinearLayout) getActivity().findViewById(R.id.send_image_overview_content); linearLayout.removeAllViewsInLayout(); int i = 0; for (Message msg : images) { // set up the imageView ImageView imageView = new ImageView(getContext()); imageView.setLayoutParams(imageViewParams); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // load the bitmap async AsyncDrawable.BitmapWorkerTask bitmapWorker = new AsyncDrawable.BitmapWorkerTask(imageView, a, a, true); imageView.setImageDrawable(new AsyncDrawable(getResources(), null, bitmapWorker)); imageView.setOnClickListener(new overviewSelectListener(i++)); bitmapWorker.execute(FileUtils.getFile(getContext(), msg.getImageUri())); // set up the background View background = new View(getContext()); background.setLayoutParams(backgroundParams); background.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark)); // make it invisible in the beginning background.setVisibility(View.GONE); // create the relativeLayout containing them RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setLayoutParams(relativeLayoutParams); relativeLayout.addView(background); relativeLayout.addView(imageView); // combination of Message and overviewViews msg.setLayout(relativeLayout); msg.setBackground(background); linearLayout.addView(relativeLayout); } } else getActivity().findViewById(R.id.send_image_overview).setVisibility(View.GONE); changePage(current, true, true); showSystemUI(); }
From source file:com.ohso.omgubuntu.BaseFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Reset the default action bar since it's global and setActionBar() would otherwise change things permanently dataSource = new ArticleDataSource(getActivity()); actionBar = ((BaseActivity) getActivity()).getSupportActionBar(); ((BaseActivity) getActivity()).getDefaultActionBar(); setActionBar();//from w w w .ja va 2s . c om RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.fragment_base_view, null, false); footerView = (TextView) inflater.inflate(R.layout.activity_main_footer, container, false); footerView.setVisibility(TextView.GONE); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); footerView.setLayoutParams(params); layout.addView(footerView); footerView.setOnClickListener(this); int columnNumber = getColumnByScreenSize(); adapter = new ArticleAdapter(getActivity(), R.layout.article_row, R.id.article_row_text_title, new Articles(), columnNumber, footerView); imageHandler = ((BaseActivity) getActivity()).getImageHandler(); adapter.setImageHandler(imageHandler); gridView = (GridView) layout.findViewById(R.id.fragment_base_gridview); gridView.setAdapter(adapter); gridView.setNumColumns(columnNumber); gridView.setScrollContainer(false); gridView.setOnTouchListener(this); gridView.setOnScrollListener(this); gridView.setOnItemClickListener(this); registerForContextMenu(gridView); getData(); if (adapter.isEmpty() || (onStartRefresh == true && getActivity().getSharedPreferences(OMGUbuntuApplication.PREFS_FILE, 0) .getBoolean(SettingsFragment.STARTUP_CHECK_ENABLED, true))) { onStartRefresh = false; setRefreshing(); } if (adapter.getCount() >= ArticleDataSource.MAX_ARTICLES_PER_PAGE && footerEnabled) { adapter.setFooterEnabled(true); } return layout; }
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
@Nullable private StickerAnnotationImageView addSticker(int imageResourceId) { RelativeLayout relativeLayout = (RelativeLayout) findViewById( R.id.supersede_feedbacklibrary_annotate_image_layout); if (relativeLayout != null) { hideAllControlItems(relativeLayout); StickerAnnotationImageView stickerAnnotationImageView = new StickerAnnotationImageView(this); stickerAnnotationImageView.setImageResource(imageResourceId); relativeLayout.addView(stickerAnnotationImageView); return stickerAnnotationImageView; }/*from w w w . ja v a 2 s.com*/ return null; }
From source file:com.hscardref.android.view.NodeSelectorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Util.trace(LogTag.LifeCycleManagement, String.format("%s: onCreateView", getClass().getSimpleName())); View rootView = inflater.inflate(R.layout.nodeselector, container, false); //kw: 3rd param must be false -- Android SDK RelativeLayout rl_nodeselector = (RelativeLayout) rootView.findViewById(R.id.rl_nodeselector); if (savedInstanceState != null) { _currentNodeType = (NodeType) savedInstanceState.getSerializable("currentNodeType"); //enum is serializable }/*w w w. j a va2 s. com*/ _nodeTypeSelector = new ComboBox<NodeType>(this.getActivity(), ImageResIds, ItemValues, _currentNodeType); _nodeTypeSelector.registerListener(new ComboBoxListener<NodeType>() { @Override public void onSelectedItemChanged(NodeType nodeType) { Util.trace(LogTag.ViewModel, String.format("[ICommand]::View NodeType changed(=%s)", nodeType)); if (_viewModel != null) { _viewModel.onNodeTypeChanged(nodeType); _currentNodeType = nodeType; } } }); rl_nodeselector.addView(_nodeTypeSelector); _lv_nodeList = (ListView) rootView.findViewById(R.id.lv_nodelist); _lv_nodeList.setOnItemClickListener(this); return rootView; }
From source file:sysnetlab.android.sdc.ui.fragments.ExperimentSensorSelectionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d("SensorDataCollector", "ExperimentSensorSelectionFragment::onCreateView(): " + "entered with mHavingHeader = " + mHavingHeader); mView = inflater.inflate(R.layout.fragment_sensor_selection, container, false); mHavingHeader = getActivity().getIntent().getBooleanExtra("havingheader", false); if (mHavingHeader) { RelativeLayout layout = (RelativeLayout) mView.findViewById(R.id.layout_sensor_selection_header); layout.setVisibility(View.VISIBLE); }/*from www . ja v a 2s .c o m*/ // find the container for the list RelativeLayout layout = (RelativeLayout) mView.findViewById(R.id.layout_sensor_selection_list); mListView = new ListView(getActivity()); if (!SensorDiscoverer.isInitialized()) SensorDiscoverer.initialize(getActivity().getApplicationContext()); List<AbstractSensor> lstSensors = SensorDiscoverer.discoverSensorList(); Activity activity = getActivity(); if (activity instanceof CreateExperimentActivity) { ((CreateExperimentActivity) activity).selectSensors(lstSensors); } else { Log.d("SensorDataCollector", "ExperimentSensorSelectionFragment::onCreate(): " + "not a CreateExperimentActivity."); } mSensorListAdaptor = new SensorListAdapter(getActivity(), lstSensors); mListView.setAdapter(mSensorListAdaptor); layout.addView(mListView); return mView; }
From source file:com.sim2dial.dialer.ChatFragment.java
private void displayImageMessage(final int id, final Bitmap image, final String time, final boolean isIncoming, final LinphoneChatMessage.State status, final RelativeLayout layout) { mHandler.post(new Runnable() { @Override/*from ww w .j a v a 2s. com*/ public void run() { BubbleChat bubble = new BubbleChat(layout.getContext(), id, null, image, time, isIncoming, status, previousMessageID); if (!isIncoming) { lastSentMessageBubble = bubble; } previousMessageID = id; layout.addView(bubble.getView()); registerForContextMenu(bubble.getView()); } }); }
From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** Presents additional information about a specific assistant. * @return a dynamically generated linear layout *//*ww w.j a v a2s.com*/ private LinearLayout getServiceDescLayout() { final LinearLayout output = new LinearLayout(this); final RelativeLayout topButtonsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); final Button btnBack = new Button(this); btnBack.setText(R.string.btnAllServices); btnBack.setId(5); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { output.setVisibility(View.GONE); getListView().setVisibility(View.VISIBLE); lblAvAssist.setVisibility(View.VISIBLE); } }); topButtonsLayout.addView(btnBack); final Button btnInvoke = new Button(this); btnInvoke.setText(R.string.btnInvokeLabel); btnInvoke.setId(6); btnInvoke.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new InvocationTask().execute(); } }); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId()); btnInvoke.setLayoutParams(layoutParams); topButtonsLayout.addView(btnInvoke); output.addView(topButtonsLayout); TableLayout serviceInfoTbl = new TableLayout(this); output.addView(serviceInfoTbl); serviceInfoTbl.setColumnShrinkable(1, true); /* FIRST ROW */ TableRow rowServiceName = new TableRow(this); TextView lblServiceName = new TextView(this); lblServiceName.setText(R.string.lblServiceName); lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceName = new TextView(this); txtServiceName.setText(selectedService); txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceName.setPadding(10, 0, 0, 0); rowServiceName.addView(lblServiceName); rowServiceName.addView(txtServiceName); /* SECOND ROW */ TableRow rowServiceDesc = new TableRow(this); TextView lblServiceDesc = new TextView(this); lblServiceDesc.setText(R.string.lblServiceDesc); lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceDesc = new TextView(this); txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceDesc.setPadding(10, 0, 0, 0); List<GateRuntimeParameter> params = null; ServiceInfoForClientArray list = getServices(); for (int i = 0; i < list.getItem().size(); i++) { if (list.getItem().get(i).getServiceName().equals(selectedService)) { txtServiceDesc.setText(list.getItem().get(i).getServiceDescription()); params = list.getItem().get(i).getParams(); break; } } TextView lblParams = new TextView(this); lblParams.setText(R.string.lblServiceParams); lblParams.setTextAppearance(getApplicationContext(), R.style.titleText); output.addView(lblParams); LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout paramsLayout = new LinearLayout(this); paramsLayout.setId(0); if (params.size() > 0) { ScrollView scroll = new ScrollView(this); scroll.setLayoutParams(txtParamsAttrbs); paramsLayout.setOrientation(LinearLayout.VERTICAL); scroll.addView(paramsLayout); for (int j = 0; j < params.size(); j++) { TextView lblParamName = new TextView(this); lblParamName.setText(params.get(j).getParamName()); EditText tview = new EditText(this); tview.setId(1); tview.setText(params.get(j).getDefaultValueString()); LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tview.setLayoutParams(txtViewLayoutParams); paramsLayout.addView(lblParamName); paramsLayout.addView(tview); } output.addView(scroll); } else { TextView lblParamName = new TextView(this); lblParamName.setText(R.string.lblRTParams); output.addView(lblParamName); } rowServiceDesc.addView(lblServiceDesc); rowServiceDesc.addView(txtServiceDesc); serviceInfoTbl.addView(rowServiceName); serviceInfoTbl.addView(rowServiceDesc); output.setOrientation(LinearLayout.VERTICAL); output.setGravity(Gravity.TOP); return output; }
From source file:com.sim2dial.dialer.ChatFragment.java
private void displayMessage(final int id, final String message, final String time, final boolean isIncoming, final LinphoneChatMessage.State status, final RelativeLayout layout) { mHandler.post(new Runnable() { @Override/*from ww w . j a v a2 s. com*/ public void run() { BubbleChat bubble = new BubbleChat(layout.getContext(), id, message, null, time, isIncoming, status, previousMessageID); if (!isIncoming) { lastSentMessageBubble = bubble; } previousMessageID = id; layout.addView(bubble.getView()); registerForContextMenu(bubble.getView()); } }); }
From source file:com.esri.arcgisruntime.sample.featurelayerupdateattributes.MainActivity.java
/** * Displays Callout// w w w. j a v a2 s.c om * @param title the text to show in the Callout */ private void showCallout(String title) { // create a text view for the callout RelativeLayout calloutLayout = new RelativeLayout(getApplicationContext()); TextView calloutContent = new TextView(getApplicationContext()); calloutContent.setId(R.id.textview); calloutContent.setTextColor(Color.BLACK); calloutContent.setTextSize(18); calloutContent.setPadding(0, 10, 10, 0); calloutContent.setText(title); RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relativeParams.addRule(RelativeLayout.RIGHT_OF, calloutContent.getId()); // create image view for the callout ImageView imageView = new ImageView(getApplicationContext()); imageView.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_info_outline_black_18dp)); imageView.setLayoutParams(relativeParams); imageView.setOnClickListener(new ImageViewOnclickListener()); calloutLayout.addView(calloutContent); calloutLayout.addView(imageView); mCallout.setLocation(mMapView.screenToLocation(mClickPoint)); mCallout.setContent(calloutLayout); mCallout.show(); }
From source file:org.csploit.android.MainActivity.java
private void createUpdateStatusText() { if (mUpdateStatus != null) return;//www .j a v a 2 s . com RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout); mUpdateStatus = new TextView(this); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mUpdateStatus.setGravity(Gravity.CENTER); mUpdateStatus.setLayoutParams(params); layout.addView(mUpdateStatus); }