I am curreny using the menudrawer from https://github.com/SimonVT/android-menudrawer.
When i try to display the menu from the top & bottom, with the apropiate gestures, i get only one response. Do you know if there can be used more than 1 menus in the same activity?
mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.TOP);
mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
mMenuDrawer.setContentView(R.layout.activity_main);
mMenuDrawer.setMenuView(R.layout.mt_main);
mMenuDrawer2 = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.BOTTOM);
mMenuDrawer2.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
mMenuDrawer2.setContentView(R.layout.activity_main);
mMenuDrawer2.setMenuView(R.layout.mb_main);
I use two menudrawers in my activity and I use them as follow (and its working for me)
mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.TOP);
mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
mMenuDrawer.setDropShadowEnabled(false);
mMenuDrawerRight = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.RIGHT);
mMenuDrawerRight.setTouchMode(MenuDrawer.TOUCH_MODE_BEZEL );
mMenuDrawerRight.setTouchBezelSize(10);
mMenuDrawerRight.setDropShadowEnabled(false);
If the library supports such a thing MenuDrawer.TOUCH_MODE_FULLSCREEN won't help at all... try with MenuDrawer.TOUCH_MODE_BEZEL
Last I checked, MenuDrawer didn't officially support multiple drawers without possibly using some kind of hack. SlidngMenu does support adding multiple drawers, wherever you want. I think MenuDrawer performs better, but SlidingMenu gives you more options and flexibility.
It is possible to attach two MenuDrawer (on left and right) to same activity
Default mode for MenuDrawer is MENU_DRAG_CONTENT but we need to use MENU_DRAG_WINDOW
Note: Don't set the ContentView for MenuDrawers
//In onCreate() of the activity
MenuDrawer slidingMenuLeft = MenuDrawer.attach(this, MenuDrawer.Type.OVERLAY, Position.LEFT, MenuDrawer.MENU_DRAG_WINDOW);
slidingMenuLeft.setMenuView(R.layout.navigation_menu_left); // Set layout for Left menu
MenuDrawer slidingMenuRight = MenuDrawer.attach(this, MenuDrawer.Type.OVERLAY, Position.RIGHT, MenuDrawer.MENU_DRAG_WINDOW);
slidingMenuRight.setMenuView(R.layout.navigation_menu_right); // Set layout for Right menu
I haven't tested this with touch mode MenuDrawer.TOUCH_MODE_FULLSCREEN
Related
import uiautomator2
device = uiautomator2.connect()
elem = device(resourceId="com.someapp.droid.full:id/publisher_content_row",
className="android.view.ViewGroup")
elem.click(5)
It is often clicking the bottom-bar or the top bar as the selected item might be hidden behind them occasionally.
Use the Barista library for UI tests, it is the easiest solution and makes everything easier. https://github.com/AdevintaSpain/Barista
With Barista, you can do it like this:
assertClickable("Hello world")
assertClickable(R.string.hello_world)
assertClickable(R.id.button)
Some other users and I are developing an Android application for the Stack Exchange chat network. We're adding a tutorial for each activity to explain the UI to the user. However, we've run into a bit of a road block.
The tutorial library wants a pointer to a view (be it a TextView, ImageView, whatever) in order to get the coordinates of the view in the display so it knows where to draw the drop shadows and stuff.
We have one activity which uses the standard "Tabbed Activity" from Android Studio, so we aren't using any custom toolbars.
The action bar looks like this:
And we want to grab a pointer to the TextView on each tab that holds the title of the tab.
So for example, we want to be able to access this Textview:
We haven't been real successful in finding anything on the internet about how to do this. It appears to be relatively easy if you're using a custom toolbar, but we aren't.
Digging in the AOSP source code, we found a potential way to do it, but the fields that we needed access to were either private or otherwise unaccessible from the main activity code.
So the question is, how can we grab a pointer to that TextView? Is it even possible?
Well, it isn't pretty but we found a way to do it. Using the layout inspector in Android Device Monitor to look at the view hierarchy, we were able to grab a pointer to it in the following way.
Keep in mind:
You may need to adjust for your activity's layout
If you're using a custom toolbar there's an easier way to do this
That being said, here's what worked for this specific use case:
ViewGroup viewGroup = (ViewGroup) getWindow().getDecorView();
LinearLayout testb = (LinearLayout) viewGroup.getChildAt(0);
FrameLayout testc = (FrameLayout) testb.getChildAt(1);
ActionBarOverlayLayout testd = (ActionBarOverlayLayout) testc.getChildAt(0);
ActionBarContainer teste = (ActionBarContainer) testd.getChildAt(1);
LinearLayoutCompat testg;
if (getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT)
{
ScrollingTabContainerView testf = (ScrollingTabContainerView) teste.getChildAt(2);
testg = (LinearLayoutCompat) testf.getChildAt(0);
}
else //Landscape
{
Toolbar teste2 = (Toolbar) teste.getChildAt(0);
ScrollingTabContainerView testf = (ScrollingTabContainerView) teste2.getChildAt(0);
testg = (LinearLayoutCompat) testf.getChildAt(0);
}
testg.setId(android.R.id.tabcontent);
//String IdAsString = testg.getResources().getResourceName(testg.getId());
//Log.e("TestG", IdAsString);
TutorialStuff.chatsExplorationTutorial(this, testg);
And here's the end result:
In google's Cardboard API we can use CardboardView.setSettingsButtonEnabled(boolean) method to hide the settings button on the bottom of the screen.
Now,Google VR API is graded to 1.0. Use GvrView insteads of 'CardboardView', and the settings button is moved to top|right when adding a close button on left|top, but I can't find any GvrView's methods which can hide the two buttons.
Please help me how to fix it, Thanks
In the current version (1.170.0) of the GVR SDK. You can find the buttons and remove them (but only in older versions of Android):
// Settings Button
val settingsButton = gvrView.findViewById<ImageButton>(R.id.ui_settings_button)
settingsButton.visibility = View.GONE
// Back Button
val backButton = gvrView.findViewById<ImageButton>(R.id.ui_back_button)
backButton.visibility = View.GONE
// Alignment Marker
val alignmentMarker = gvrView.findViewById<RelativeLayout>(R.id.ui_alignment_marker)
alignmentMarker.visibility = View.GONE
Yes ,I think the developers don't plan to add this method.
[https://github.com/googlevr/gvr-android-sdk/issues/252][1]
Instagram on Android recently add new feature, when user long click to items at the Browse section, a popup menu shows and allow user to pre-view photo/video instead of going to its details.
It is really cool like iOS force touch feature.
Does anyone know any idea how we can do the same on Android app?
Can we just use Context Menu or Overlay Window to do that?
Thanks
Now I can do quite the same on UI with this library
https://github.com/tvbarthel/BlurDialogFragment
But the thing is:
When I long press the button, I have to RELEASE my finger to continue touching the dialog fragment. The touch event is still sent to activity not DialogFragment.
Do you know how to pass touch event / focus to dialog fragment right after it is showed?
It's the closest library I've found on the internet,
https://github.com/nantaphop/HoverTouchView
it might not be exactly like IG's, but for sure it gives the idea
I Have found 3DTouch as well as in Instagrame.
This library is hosted on Jitpack.io, which means to use it you will have to add the following to your root build.gradle file.
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
And then you will need to add the following dependency to your applications build.gradle file.
dependencies {
compile 'com.github.shalskar:PeekAndPop:v1.0.1'
}
Usage:
Basic usage is easy, simply provide an activity instance, a layout resource for the peek and pop and 1 or more views that will show the peek and pop when long clicked.
PeekAndPop peekAndPop = new PeekAndPop.Builder(this)
.peekLayout(R.layout.peek_view)
.longClickViews(view)
.build();
You can get the peek view by calling getPeekView() on the PeekAndPop object, and use findViewById() to get access any views in the peek layout.
View peekView = peekAndPop.getPeekView();
ImageView imageView = peekView.findViewById(R.id.image_view);
TextView textView = peekView.findViewById(R.id.text_view);
Often you will want to have the peek and pop shown when an item in a list (or other scrollable view) is clicked on, to ensure the peek and pop works correctly, you will have to add this line of code:
.parentViewGroupToDisallowTouchEvents(viewGroup)
How can I clone this behaviour (iOS) on an Android-App?
Technically its definitly possible as I have an app by my own on my Androidphone - its an Email-App with a very similiar indicator on the Icon. (shows the number of unread Emails)
yes you can implement overlay like ios.. by the way it is called badge value.
here is one sample available on github
You just have to add classes in your project and call below lines
View target = findViewById(R.id.target_view);
BadgeView badge = new BadgeView(this, target);
badge.setText("1");
badge.show();
hope it helps.
If you are referring to doing this on the home screen, that is an app widget.