How to eliminate TabLayout scroll jumping (skipping) in Android TV when there are more than 64 tabs? - android-tablayout

I’m trying to implement tab navigation in my Android TV app using TabLayout. There are many tabs so I have enabled “scrollable” mode.
When I'm trying to navigate through the tabs (from left to right) using remote control the tab indicator does not move to the very next tab but jumps far to the right, and again and again until it reaches some position. After this position is reached, tab indicator start moving normally.
I have experimented a little and found that this abnormal scrolling behavior appears only when number of tabs in TabLayout is more than 64
First I met this problem with TabHost and changed my code to use TabLayout, but problem persists.
I have played with all relevant options with different combinations but nothing worked.
Below is the fragment of my layout file
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="false"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:background="#color/black_opaque"
android:fillViewport="true"
android:measureAllChildren="true"
android:nestedScrollingEnabled="false"
android:padding="2dp"
app:tabGravity="center"
app:tabMode="scrollable"
app:tabTextAppearance="#style/TextAppearance.AppCompat.Medium" />
<GridView
android:id="#+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4" />
</LinearLayout>
I have recorded the video to show how it looks like:
scroll_skipping.mp4
What do I missing? How to configure TabLayout to avoid such behavior?

Finally I couldn’t find any solution, it looks like bug or TabLayout limitation.
So I have changed the layout and did what I need with ListView.
Conclusion - TabLayout is for limited number of tabs, no more than 64, less is better.

Related

MSHTML editing - changing the text selection color

I use MSHTML (TWebBrowser control) in Design (edit) mode. I use TEmbeddedWB but slowly moving away from that component and implementing my own interface. When a block of text is selected, so when typing into the editor and then selecting a block of text it is in black color for the background color.
Instead I'd like to use blue.
I know that it has something to do with the selection range but not sure how to modify it in designer mode. The code below is of course when it is not in design mode.
IHTMLSelectionObject currentSelection = document.selection;
IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange;
if (range != null)
{
range.execCommand("BackColor", false, "0000FF");
}
Any ideas? Do I have to use event sinking? Or maybe QueryCommandValue? I tried some things with HiliteColor without success yet (according to Mozilla documentation this is not supported by Internet Explorer).
I use C++ Builder or Delphi, but code example in any language is welcome, I can (probably) translate it.

decrease padding in GTK3 buttons

Since the last update pack of Linux Mint Debian, GTK3 buttons suddenly need more width than before, so that they don't fit in an application I wrote. The problem is that they allocate more space around the button label (something like 25 pixels each side), and cannot be convinced not to do so.
The button was created with gtk_button_new_with_label, so nothing fancy.
I tried everything to reduce that wasted space, but nothing worked:
gtk_widget_set_size_request(GTK_WIDGET(mybutton),1,1); does nothing.
gtk_widget_set_margin_right(sidebar.button[i],0); decreases the spacing around the button, not inside.
gtk_container_set_border_width(GTK_CONTAINER(mybutton),0); decreases the spacing around the button, not inside.
what have I missed?
I guess that's defined in the stylesheet of the theme you are using. You can try overriding the style of the widget using GtkCssProvider. A python example could look something like
my_style_provider = Gtk.CssProvider()
my_style_provider.load_from_data(b'GtkWidget { padding-left: 0; padding-right: 0; }')
context = widget.get_style_context()
context.add_provider(my_style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Note: untested.

Touch Up Inside event not working after rotation of tab bar

I have a button in one of view controller of tab bar controller. All set up in storyboard. I registered action method like this
- (IBAction)buttonPressed:(id)sender {
NSLog(#"Button pressed");
}
The thing is that once I make left and top constraints (to force it stay in the right upper corner) touch up inside event stops working after I change rotation. So just open app in portrait mode - method is working. Change to landscape and I cannot tap button suddenly.
I've recreated problem in this easy example project.
Many thanks.
Just put the following code in you TabBarViewController class.
- (void)viewDidLayoutSubviews
{
// fix for iOS7 bug in UITabBarController
self.selectedViewController.view.superview.frame = self.view.bounds;
}
Recently I noticed same bug in my application. First I tried Slavco Petkovski method. But this caused me another bug with rotating and getting right bounds and frame, so I kept searching.
I found another solution for this problem, mainly setting autoresizing mask of view controller's view in xib. But since arrows in inspector in my Xcode (version 5.0.1) are inactive and you can't set them, you have to open xib file in text editor find autoresizingMask property for main view and change it like this:
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
EDIT:
Alternatively you can do this in your view controller's code - same result as in changes in xcode:
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

Google Glass GDK: Progress Indicator?

Using the GDK (or in some other way), is there a way to display a progress indicator similar to the one displayed when connecting to a WiFi network on Glass? (the "spinning" lines on the bottom of the display, kind of like at the end of this video: https://www.youtube.com/watch?v=g3ncmeGaKN0)
Thanks!
UPD 04.11.2014: Google released Slider -- UX component suitable for this. You should better use it instead of the extracted project.
I've extracted Google Glass Progress Bar from GlassHome.apk and created a library project based on that: https://github.com/pif/glass-progress-bar
supports indeterminate
supports default progress
Usage is described in README in the repository.
And yes, everyone is still waiting for a full-featured set of Glass Views.
Update: I extracted MessageDialog as well. You can find it in the same library.
This issue is resolved by google with Slider (global UX Components) https://developers.google.com/glass/develop/gdk/slider
This comes pretty close, but the color is off (blue/teal/whatever instead of white).
style="?android:attr/progressBarStyleHorizontal"
Sample (via OkGlassFindACat):
<ProgressBar
android:id="#+id/someProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
I definitely haven't figured out how to override that color, though.
I know I'm late but here's my version :)
https://github.com/prt2121/glass-gdk-progressbar
adding to your project in the gradle file
compile 'com.github.prt2121:ProgressBar:1.0#aar'
screenshot:
changing color
app:progress_color="#android:color/holo_blue_bright"
The GDK overrides themes for some widgets automatically to provide a proper Glass-like appearance, such as TextView. For widgets that don't yet have that theming, please file an issue here so that we can track it.
I put together the answer above to create a general layout for my card-list loader activities. Here's the layout file card_scroll_with_progress_layout.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black">
<com.google.android.glass.widget.CardScrollView
android:id="#+id/card_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="#+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</FrameLayout>
Then in the onCreate I get the progress bar and set it rolling:
View rootLayout = getLayoutInflater()
.inflate(R.layout.card_scroll_with_progress_layout, null);
mProgressBar = (ProgressBar)rootLayout.findViewById(R.id.progress_bar);
mProgressBar.setVisibility(View.VISIBLE);
mCardScrollView = (CardScrollView)rootLayout
.findViewById(R.id.card_scroll_view);
mCardScrollView.setAdapter(mAdapter);
setContentView(rootLayout);
Later on in my loader callback I hide the progress bar and activate the card scroll view:
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (loader.getId() == mLoaderId) {
mAdapter.swapCursor(data);
mProgressBar.setVisibility(View.GONE);
mCardScrollView.activate();
}
}
This seems to be working well as a paradigm for handling various json loading into a list of cards in the GDK.
We have been having a similar issue and found a hybrid approach that works for us. We use the standard progress bar #patridge mentioned in a previous post and applied generated Holo styles provided by Android Holo Colors.
We were able to generate a white progress bar images, animation, layer and style that looks very similar to the built in GDK version. You can increase the height of the bar to match the GDK by editing the size of Holo Color's generated png images.
You will need the generated files included in your project, but here is what our theme looks like afterwards:
<style name="OurGlassTheme" parent="#android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">
<item name="android:progressBarStyleHorizontal">#style/ProgressBarGlass</item>
</style>
<style name="ProgressBarGlass" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/glass_progress_horizontal_holo_light</item>
<item name="android:indeterminateDrawable">#drawable/glass_progress_indeterminate_horizontal_holo_light</item>
<item name="android:minHeight">16dip</item>
<item name="android:maxHeight">16dip</item>
</style>
I know it's super tedious, but it gets us there while #giladgo 's accepted submission to the Glass developers to provide a GDK Progress Bar is finished.
Try to use ProgressBar from zoom-in project.

Unit testing android listview scrolling using Roboelectric

I have a method that attempts to programatically scroll to a position in a ListView. The method has some conditionals so that its implementation differs slightly based on the Android SDK version the app is running on.
The functionality works fine on 3 android devices that I have tested on. However, I have written a unit test using junit and Roboelectric that checks if the scrolling has made the the item at the target position visible. The test fails. When I debug, I notice that android.os.Build.VERSION.SDK_INT is 0 when running with Roboelectric (i.e., on the desktop vs. device or emulator).
I've tried ignoring the version and just using ListView.smoothScrollToPosition(), but the getFirstVisilePoition() and getLastVisiblePosition() methods continue to return 0, even immediately after I call smoothScrollToPosition(150).
Does anyone know if/how scrolling a listview can be tested using Roboelectric?
Any help would be appreciated - I can't seem to find any information on the topic.
Thanks,
Ana
If you're using robolectric 1.1 or 1.2, here is the source for the AbsListView:
https://github.com/pivotal/robolectric/blob/master/src/main/java/com/xtremelabs/robolectric/shadows/ShadowAbsListView.java
It looks like all the scrolling functionality is it ShadowAdapterView:
https://github.com/pivotal/robolectric/blob/master/src/main/java/com/xtremelabs/robolectric/shadows/ShadowAdapterView.java
It doesn't look like getFirstVisiblePoition() or getLastVisiblePosition() are implemented.
I was able to get the smooth scroll position.
#RunWith(RobolectricTestRunner.class)
public class SmoothScroll {
#Test
public void testSmoothScroll() {
Activity context = new Activity();
ListView view = new ListView(context);
view.smoothScrollToPosition(100);
Assert.assertEquals(100, Robolectric.shadowOf(view).getSmoothScrolledPosition());
}
}
You can get the smooth scrolled position. Based on the height of the elements, you may be able to work out which ones are visible.