I created custom switch button using two textview components. Is there any easy way to give one element on the another using OnClickListener ?
Example:
Why did you make your own? Android already provides Switches where you don't have to worry about any of this stuff since it is already implemented. Specifically you want the Toggle Button (changes to a switch button in Android 4.0+).
This way you will be providing users controls which are specific to their platform and match other similar applications that they use.
Related
In my Android app I have a custom layout that is being used as a button - it consists of some TextViews and an ImageView, additionally it has some gradient background.
I'm aligning my app now to conform to the Accessibility rules. In order to do so, I would need to convert this layout into a button, so that TalkBack can correctly indicate the action, that this whole layout is clickable and serves like a button.
I know that on iOS there is a possibility to set the UIAccessibilityTraits to treat such view as a button - this kind of solution would save me a huge amount of work in terms of migration.
Is there any similar solution on Android for that? What approach should I follow in order to make this layout recognized correctly by TalkBack?
No, there's no concept of accessibility traits on Android - but you can still get a good accessibility experience without needing to specifically convert your layout into a Button.
Generally, it's most important that TalkBack (or whatever accessibility service is being used - remember, it's not just TalkBack) is able to detect that the widget is clickable and to be able to read a coherent description of what it does. The additional information that it's a button, specifically, isn't super useful, especially because there are so many different kinds of UI elements that it's often a very ambiguous question whether something even is a button.
You can test this by selecting it in TalkBack and confirming that it reads the content description properly, says something along the lines of "Double tap to activate," and performs the correct action when you double tap.
If it's not correct, make sure the content description, clickable flag, and click action are set correctly on the widget's AccessibilityNodeInfo.
Is it possible to have a custom layout for 'ExpandedControlsActivity' in an android application? I want to add a button to the standard layout which will allow the user to choose from different video streams (low/high).
At the moment i am using the standard one;
Google codelabs - Cast SDK v3 Android Codelab
No, you do not have control over the layout. You can only use one of the pre-defined actions for the buttons on that screen. You can, however, write your own custom activity and have that act as the Expanded Controller (i.e. be invoked if user, say, taps on the mini controller). Given that it is easy to use UiMediaController to bind ui components of your app to the remote session, writing such activity shouldn't be too much trouble.
For addition of any custom layout you need to modify activity_layout.xml and activity.java in order to add the feature.
But you dont have Access to the ExpandedControlsActivity layout file as it is extended from ExpandedControllerActivity.
So only way is to write your own activity and than use that instead of ExpandedControlsActivity.
I am developing an app that can post two kinds of questions. to switch views i need a switch button on the TOP. i need help to customize my switch button like following image.
I used below gihub library for this type of button
https://github.com/kyleduo/SwitchButton
Advantage:
customize as per color you want
with good animation of switching button
I want to create a set of pages in an Android app that swipe horizontally and use tickmarks to indicate the position of the current page within the set of 12 pages that I have.
The design pattern of using tickmarks like this is mentioned in the Android design documentation.
http://developer.android.com/training/design-navigation/descendant-lateral.html
See figure 7
Are tick marks implemented as part of class within Android or do I need to create my own? Has anyone implemented tick marks who would be happy to share their code?
If you don't want to use a third party or you are rushing, you may want to use a RadioGroup as the tickmark or page indicator with each of the RadioButton corresponds to each page, You may put a text label on each page and the radio button group must be in horizontal orientation just like the tickmark.
It will also add some intuitive function because when the user tick a radio button it will go directly to the intended page without needing to traverse all of the pages.
This library by JakeWharton looks like it will do the job.
http://viewpagerindicator.com
I'm using the framework from here - cardsui
How can I add a share button to the top of the cards. I've implemented it in the xml with an on click method, but the app crashes when I press it and says that the method doesn't exist (yes, I added the method to the main java file. also to the card.java file but still the app crashes...).
Has anyone used this framework and encountered this?
Thank you
You might want to check this addon for CardsUI: https://github.com/Androguide/cardsui-for-android
As developer wrote:
The Google Play cards come with more customization parameters than the other regular cards, those parameters include :
Title (String)
Description (String)
Stripe color (String)
Title Color (String)
Enable an overflow menu on the card. It's not finished yet, I still
need to implement the popup menu when clicked (Boolean)
Enable touch feedback on click or disable it (Boolean)
If you replace the overflow menu with buttons, at least you get a boolean and then handle the actions accordingly.
I wonder if you should just use a simple ListView, and apply a custom background to your adapter to give it the card UI. Then you are just using a simple ListView (with no additional framework - ie. just standard Android UI).
I describe how I did this in the following SO answer: How to create Google + cards UI in a list view?
I would guess that you ARE able to add an onClickListener to the component of your card, as this is pretty standard Android (chances are the Framework you are using DOES support this). Don't know your specific issue unless you post more code.