Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. @Override
  2. protected void onCreate(Bundle savedInstanceState) {
  3. super.onCreate(savedInstanceState);
  4. setTheme(R.style.Backup);
  5. setContentView(R.layout.activity_add_element);
  6.  
  7. getSupportActionBar().setElevation(0);
  8. getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  9. getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(getApplicationContext(), R.color.actionbar)));
  10. setTitle("Add element");
  11.  
  12. Display display = getWindowManager().getDefaultDisplay();
  13. Point size = new Point();
  14. display.getSize(size);
  15. width = size.x / 2;
  16.  
  17. // Add the element selector box
  18. TextView metric = new TextView(this);
  19. metric.setText("Element type: ");
  20. metric.setId(View.generateViewId());
  21. Spinner spinner = new Spinner(this);
  22. spinner.setPadding(400, spinner.getPaddingTop(), spinner.getPaddingRight(), spinner.getPaddingBottom());
  23. spinner.setId(View.generateViewId());
  24. String[] items = new String[]{"Boolean", "Counter", "Slider", "Chooser", "Checkbox", "Stopwatch", "Text field", "Gallery", "Database card"};
  25. ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.support_simple_spinner_dropdown_item, items);
  26. spinner.setAdapter(adapter);
  27. spinner.setSelection(0);
  28. RelativeLayout layout = new RelativeLayout(this);
  29. layout.addView(metric);
  30. layout.addView(spinner);
  31. layout = addFields(metric.getId(), layout, 0);
  32.  
  33. CardView card = new CardView(getApplicationContext());
  34. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
  35. params.addRule(RelativeLayout.CENTER_HORIZONTAL);
  36. card.setLayoutParams(params);
  37. card.setRadius(0);
  38. card.setContentPadding(30, 30, 30, 30);
  39. card.setUseCompatPadding(true);
  40. card.setCardBackgroundColor(Color.DKGRAY);
  41. card.addView(layout);
  42. LinearLayout fLayout = (LinearLayout) findViewById(R.id.add_element_layout);
  43. fLayout.addView(card);
  44.  
  45.  
  46. }private void addCard(View layout) {
  47. CardView card = new CardView(getApplicationContext());
  48. LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
  49. card.setLayoutParams(params);
  50. card.setRadius(9);
  51. card.setContentPadding(30, 30, 30, 30);
  52. card.setUseCompatPadding(true);
  53. card.setCardBackgroundColor(Color.DKGRAY);
  54. card.addView(layout);
  55.  
  56. Toolbar tl = (Toolbar) findViewById(R.id.toolbar);
  57. tl.removeAllViews();
  58. tl.addView(card);
  59. }
  60.  
  61. <ScrollView
  62. xmlns:android="http://schemas.android.com/apk/res/android"
  63. xmlns:tools="http://schemas.android.com/tools"
  64. android:layout_width="match_parent"
  65. android:layout_height="match_parent"
  66. android:fillViewport="true"
  67. xmlns:app="http://schemas.android.com/apk/res-auto"
  68. tools:context="com.cpjd.roblu.activities.TeamViewer">
  69. <LinearLayout
  70. android:id="@+id/add_element_layout"
  71. android:layout_width="match_parent"
  72. android:layout_height="wrap_content"
  73. android:orientation="vertical">
  74.  
  75. <android.support.v7.widget.Toolbar
  76. android:id="@+id/toolbar"
  77. android:minHeight="?attr/actionBarSize"
  78. android:layout_width="match_parent"
  79. android:layout_height="wrap_content"
  80. android:background="#A52A2A"
  81. app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
  82. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement