Focusing button by default in android tv - android-tv

I have an Android tv Layout with two buttons:
Buttons are not focused
I want one button to be focused by default:
Focusing choose a TV button by default.
I have tried a few methods.
In java file
final Buttonspinner spinner = findViewById(R.id.choose_folder);
spinner.requestFocus();
spinner.setFocusable(true);
In xml
android:state_focused="true"
Still, it's not getting focused by default.
How can I achieve this?

In code:
spinner.setFocusableInTouchMode(true);
spinner.setFocusable(true);
spinner.setFocusedByDefault(true);
spinner.requestFocus();
Alternatively in XML:
<Button
android:id="#+id/choose_folder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose"
android:focusableInTouchMode="true"
android:focusable="true"
android:focusedByDefault="true">
<requestFocus/>
</Button>
Maybe a bit overkill, but either one of these should cover all bases.

Related

How can I implement fragment animation?

I have read the documentation for the Animate transitions between fragments and implemented it into my code. I have seen videos on how to make animations when switching from fragment to another,
but nothing happens.
This is the code in my Main Activity for replacing the fragment by another:
getSupportFragmentManager().beginTransaction().replace(R.id.frag_container, fragment)
.setCustomAnimations(R.anim.slide_in, R.anim.slide_out)
.commit();
I tried to use the addToBackstack() method to see if it has something with the animation, but nothing happens.
The fragment in the code above is made when I press on a BottomNavigationView item.
Here's the XML content for the animation in and out:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="#android:integer/config_shortAnimTime"
android:interpolator="#android:anim/decelerate_interpolator"
android:fromXDelta="100%"
android:toXDelta="0%" />
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="#android:integer/config_shortAnimTime"
android:interpolator="#android:anim/decelerate_interpolator"
android:fromXDelta="0%"
android:toXDelta="100%" />
The problem was that I replaced the fragment first and then I applied
the animation. It has an order:
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(R.anim.slide_in,R.anim.slide_out)
.replace(R.id.frag_container, fragment)
.comit()

Fit title text on a tabbedpage xamarin forms?

Hello friends how are you?
I tell you that I have a tabbedpage that aims to show a list of elements. These elements have different states and not to saturate a listview, I decided to create a tab for each state. This works well, the only problem is that the text of the tabs titles are cut. I understand that it is because of the screen size. But I have seen apps that have multiple tabs that are hidden and when they press other tabs they appear.
In summary, how can I make the text appear complete in the tab titles? Try WidthRequest, but this does not work. I thank you for the help you can give me.
<ContentPage Title="Tab 1" MinimumWidthRequest="222" WidthRequest="222" />
<ContentPage Title="Tab 2" MinimumWidthRequest="222" WidthRequest="222" />
<ContentPage Title="Tab 3" MinimumWidthRequest="222" WidthRequest="222" />
You could reset the app:tabMode from "fixed" to "scrollable".
In Xamarin.forms, Android> Resources> layout> Tabbar.xml:
Change:
app:tabMode="fixed"
To:
app:tabMode="scrollable"
Please make sure you have the code below in your MainActivity.
TabLayoutResource = Resource.Layout.Tabbar;

OpeneERP: How to create a button with no icon (only text on it)

I would like to create a button with no icon, only a text that i display.
I 've tried to not put 'icon' parameter but it doesn't work.
Here's the code i've wrote:
<button name="open_popup" string="Quantités produites" type="object"/>
i've known a possibility, but i think that was a listview bug in chrome or something.
maybe you should try class="oe_link" on your button, so it looks like a link.
<button name="open_popup" string="Quantités produites"
type="object" class="oe_link"/>
In version 7 you can use class="oe_link":
<button name="open_popup" string="Quantités produites" type="object" class="oe_link"/>

FontAwesome, Bootstrap and screenreader accessibility

I'm wondering about screen reader accessibility using Twitter Bootstrap framework and FontAwesome icon fonts.
I'm looking at 2 different icon situations:
1) The icon has helper text that a screen reader will pick up:
<span class="fa fa-pencil"></span> Edit
2) And a standalone icon without any helper text:
<span class="fa fa-pencil"></span>
Ideally, in both situations, a screen reader will announce that the element is an "Edit" button.
Per FontAwesome's site:
Font Awesome won't trip up screen readers, unlike other icon fonts.
I don't see any speech css tags related to FontAwesome or Bootstrap and not really clear to me how a screen reader will react to each of these situations.
I'm also aware of aria-hidden and Bootstrap's .sr-only and there has to be an ideal way to handle both situations.
Edit: added title="Edit to example 2.
What advantage does using aria-label="Edit" have over the standard title="Edit"?
Edit 2: I came across this article that explains pros and cons of different use implementations.
First of all, you should probably use <button> instead of <a href="#">. Empty links can be confusing for screen readers, but a button is a button. In short, links take you places, buttons perform actions. (http://www.karlgroves.com/2013/05/14/links-are-not-buttons-neither-are-divs-and-spans/; https://ux.stackexchange.com/questions/5493/what-are-the-differences-between-buttons-and-links).
I would go with a variation of your first code sample, and utilize Bootstraps .sr-only class. If we update your code with button and add in the class, we have:
<button type="button" class="btn btn-default"><span class="fa fa-pencil"></span> <span class="sr-only">Edit</span></button>
We now have a more semantically correct button element; sighted users see the edit pencil icon; and screen reader users will hear "Edit". Everyone wins.
(Note, the button code is straight from Bootstraps CSS Buttons section.)
From my understanding I think it may be useful to also add in:
aria-hidden="true"
to the span class that holds the pencil icon. This will prevent the screen reader from trying to read this element.
<span class="fa fa-pencil" aria-hidden="true"></span>

wcag compliance issue with play/pause button

As part of making our site WCAG compliance we are adding play/pause buttons for carousel.Here the screen reader is reading in different manner
<div id="imageCarouselPlayBtn" class="cblt-button imageCarouselPlayBtn" tabindex ="0">
►
</div>
<div id="imageCarouselPauseBtn" class="cblt-button imageCarouselPauseBtn" tabindex ="0">
‖
</div>`
in this case screen reader is reading pause button as double vertical line and group for play button.
if we use sprite image instead it is reading as group for both play/pause buttons.
Is there any good solution for this problem instead of using image tags for both ?
You could use WAI-ARIA’s aria-label attribute:
It provides the user with a recognizable name of the object.
Also: Is there a reason why you don’t use button/input instead of div for the play/pause buttons? With buttons, your markup could look like:
<button type="button" aria-label="Play">►</button>
<button type="button" aria-label="Pause">‖</button>

Resources