Guest User

Untitled

a guest
Feb 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. <android.support.v7.widget.CardView
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:card_view="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="90dp"
  5. android:layout_height="130dp"
  6. android:id="@+id/card_view"
  7. android:layout_margin="5dp"
  8. card_view:cardCornerRadius="12dp"
  9. card_view:cardElevation="3dp"
  10. card_view:contentPadding="0dp"
  11. card_view:cardBackgroundColor="@color/lightBrown"
  12. android:foreground="?selectableItemBackground"
  13. android:clickable="true">
  14. <LinearLayout
  15. android:layout_width="match_parent"
  16. android:layout_height="match_parent"
  17. android:background="@drawable/button_card_unlocked_bg"
  18. android:orientation="vertical"
  19. android:padding="5dp">
  20. <LinearLayout
  21. android:id="@+id/prvniLin"
  22. android:layout_width="match_parent"
  23. android:layout_height="wrap_content"
  24. android:orientation="vertical">
  25. <ImageView
  26. android:id="@+id/imgView"
  27. android:layout_width="match_parent"
  28. android:layout_height="50dp"
  29. android:layout_gravity="center"
  30. android:layout_margin="3dp"
  31. android:src="@drawable/kostka" />
  32. </LinearLayout>
  33. <LinearLayout
  34. android:layout_width="match_parent"
  35. android:layout_height="wrap_content"
  36. android:orientation="vertical"
  37. android:layout_marginTop="1dp"
  38. android:layout_marginHorizontal="3dp">
  39. <LinearLayout
  40. android:layout_width="match_parent"
  41. android:layout_height="26dp"
  42. android:background="@color/blueDark"
  43. android:padding="5dp">
  44. <TextView
  45. android:id="@+id/date"
  46. android:layout_width="match_parent"
  47. android:layout_height="wrap_content"
  48. android:text="Datum nálezu: "
  49. android:textColor="@color/white"
  50. android:textSize="6dp" />
  51. </LinearLayout>
  52. </LinearLayout>
  53. </LinearLayout>
  54.  
  55. LayoutInflater inflater = (LayoutInflater) getActivity()
  56. .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  57. View v = inflater.inflate(R.layout.card_layout_unlocked, null);
  58. MarkerOptions mO = new MarkerOptions().position(new LatLng(mData.getLat(), mData.getLng())).title(mData.getTitle()).icon(BitmapDescriptorFactory.fromBitmap(loadBitmapFromView(v)));
  59. Marker m = mMap.addMarker(mO);
  60.  
  61. public static Bitmap loadBitmapFromView(View v) { //Source: https://stackoverflow.com/questions/2801116/converting-a-view-to-bitmap-without-displaying-it-in-android
  62. if (v.getMeasuredHeight() <= 0) {
  63. v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
  64. Bitmap b = Bitmap.createBitmap(v.getMeasuredWidth(), v.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
  65. Canvas c = new Canvas(b);
  66. v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
  67. v.draw(c);
  68. return b;
  69. }
  70. return null;
  71.  
  72. }
Add Comment
Please, Sign In to add comment