Add button inside AndroidXMapFragment in here maps - here-api

I'm using the here android SDK and started with the BasicMapSolution tutorial.
Now I want to add buttons on top of the map (zoom in/zoom out/center view to my position).
Unfortunately I did not figure out how to do it.
I tried adding a button in activity_main.xml like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- Map Fragment embedded with the map object -->
<fragment
android:id="#+id/mapfragment"
class="com.here.android.mpa.mapping.AndroidXMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/activity_main">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|top"
android:text="Demo Button"
android:padding="10dp"
android:layout_marginTop="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"/>
</fragment>
</LinearLayout>
But the button is not shown in the app. Can anyone help please. Just to make it clear, I want to achieve something like this:

Are you not able to do a zoom using 2 finger tap ? https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics/map-gestures.html
Map gesture customisation can also be done. In case adding zoom controls is requirement then you can add a map marker object of unknown type, and pass zoom in min max range on its listener in premium SDK. As of now, traditional zoom in/zoom button add on controls are not available. you can refer below API documentation to check for mapobject and zoom range in details.
https://developer.here.com/documentation/android-premium/3.15/api_reference_java/index.html
Also refer to our github example for map marker objects and gestures that are already available >
https://github.com/heremaps/here-android-sdk-examples/blob/master/map-objects/app/src/main/java/com/here/android/example/map/objects/MapFragmentView.java

Related

Replacement of deprecated BrowseFragment AndroidTV

This class was deprecated in API level 27.1.0.
use BrowseSupportFragment
But when i replaced this
public class MainFragment extends BrowseFragment
to
public class MainFragment extends BrowseSupportFragment
bellow exception is occurring
Caused by: android.app.Fragment$InstantiationException: Trying to instantiate a class MainFragment that is not a Fragment
My XML code is
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.example.tvapplocation1.MainFragment"
android:layout_width="match_parent" android:layout_height="match_parent">
</fragment>
Short answer: This can happen if your Activity does not extend from FragmentActivity.
Longer answer: There are two versions of the Fragment class, one that's built into the OS and one that's part of the support/Android X libraries (). You should always use the support/Android X version because it provides compatibility and consistent behavior across Android OS versions. The various *SupportFragment classes (like BrowseSupportFragment) extend from the support/Android X version of Fragment, which require you to use the FragmentActivity from the support/Android X libraries.

How to create signup button like this in android studio?

how to create button like this.I am new in android.I am trying to create this from last 3 days.
You can create XML using designer in Android Studio or
Go to res/layout/activity_main then XML file will be open then add
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>

Android scratch View 2 Layers

I'm using Android-WScratchView to implement a scratch effect in my app.
What my app does is a "cleaning" effect. I have a picture of a clean t-shirt and another picture of the same t-shirt but dirty (with some mud).
Android-WScratchView works great for the normal case, a background Image (clean t-shirt) and an overlay Image (dirty t-shirt).
The problem is now, I need to add a second overlay Image, which is a "less" dirty t-shirt so the user has to "clean" the t-shirt in 2 steps.
Once the first layer has been erased, I need to be able to erase the second layer but only where it is visible.
I've implemented it using 2 WScratchView objects, one behind another, like this:
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/shirt_clean" />
<com.winsontan520.WScratchView
xmlns:wsv="http://schemas.android.com/apk/res-auto"
android:id="#+id/scratch_view_layer_1"
android:layout_width="300dp"
android:layout_height="300dp"
wsv:antiAlias="true"
wsv:revealSize="20dp"
wsv:scratchDrawable="#drawable/shirt_less_dirty"
wsv:scratchable="true" />
<com.winsontan520.WScratchView
xmlns:wsv="http://schemas.android.com/apk/res-auto"
android:id="#+id/scratch_view_layer_2"
android:layout_width="300dp"
android:layout_height="300dp"
wsv:antiAlias="true"
wsv:revealSize="20dp"
wsv:scratchDrawable="#drawable/shirt_dirty"
wsv:scratchable="true" />
The problem is that after the "most dirty" layer is "erased" (it gets transparent) I cannot delete the "less dirty" layer because the second layer is getting the onTouch event.
My idea is parsing somehow the onTouch event through the second WScratchView to the first one. But still would have the problem that I don't know which area has already been deleted and which not.
I would appreciate any help, also a different way to implement it will be accepted.

Activity or Fragment or?

I have the the following Activity LinearLayout.
<!-- Main LinearLayout -->
<LinearLayout
...
android:orientation="vertical"
tools:context=".MainActivity">
<!-- Inner LinearLayout -->
<LinearLayout... />
<!-- Fragment holding Google Map Fragment -->
<fragment android:name=".MainMapFragment"
android:id="#+id/map_fragment"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="match_parent" />
<!-- Inner LinearLayout -->
<LinearLayout... />
</LinearLayout/>
I have some Google Map Markers displayed in the MainMapFragment showing that around that location there are some specific related business to look into.
Once a User clicks on any of those Markers on the Map... I need to display a LIST of all those Business associated to that MARKER and allow the User to Tag/Mark the business as FAVORITE or NOT.
I have everything done in relation to the Google Map, Markers, InfoWindow, etc... however... I would like to know what should be a good way/design/layout to DISPLAY the Business List (ListView is ok) detail information and allow the User to MARK AS FAVORITE any of the business in the list using a REGULAR BUTTON (or TOGGLE BUTTON) display within the Business Information Details.
Although I already thought on some choices (see below), I am not sure which one to go for it.
Launch a new Activity, once back (new activity finished) update the information within the Map, Markers, etc.
Add a new Fragment to the current Layout and SWITCH (hide/show) between the one with the Map and the one with the Business Information.
A Modal Dialog (DialogInterface, AlertDialog, etc)
Once again I am not sure where to go and so my question... what will be a good design/model to approach this request?
Sorry for my english, i think that you should use an activity, If I understood correctly on click event you should display details of the related place, a good habit of mobile programming is to display details in other activity with the back button in the action bar.
I ended up extending DialogFragment, not only works OK but also allowed me to work with anything in a custom/complex layout inside the Dialog.

Android Layout: Consistent visible Button Bar

In my main Activity I have created a bar with buttons on it. Now , I would like the "Button Bar" to always show regardless of what Activity I'm showing. Basically I need the handle the Button events from the "Button Bar" across all Activities. Is this possible, and what best practice to achieve this?
Use includes inside a Merge. The includes can be re used inside any view.
<com.testmerge.TitleBar
id="#+id/titlebar"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_gravity="top"
android:paddingTop="0dip"
android:background="#drawable/title_bar"
/>
<com.testmerge.OkCancelBar
android:layout_width="fill_parent"
android:layout_height="60dip"
android:layout_gravity="bottom"
android:paddingTop="0dip"
android:background="#drawable/header_bkgrnd"
/>
<!--"#AA000000"-->

Resources