In my app, Talkback is not pronouncing the name of the button. Instead it's just pronouncing as "button".
Can anyone help me to do the task?
I tried the following xml
<Button
android:id="#+id/loginsuccess"
android:scaleType="fitXY"
android:layout_width="100dp"
android:layout_height="30dp"
android:background="#drawable/submit_button"
android:layout_alignParentRight="true"
/>
that's not working
You should add the following in button xml declaration:
android:contentDescription="buttonName"
I simply added a property android:contentDescription=" " in the xml file, Like the following
<Button
android:text="Login"
android:textSize="0sp"
android:id="#+id/loginsuccess"
android:scaleType="fitXY"
android:layout_width="100dp"
android:layout_height="30dp"
android:background="#drawable/submit_button"
android:contentDescription="login"
android:layout_alignParentRight="true"
/>
that solved the problem.
For reference it was because you didn't have android:text so there was nothing to read out.
You must Content description is set on Button. Like this android:contentDescription="login"
Related
I have RecyclerView include ImageButton play each item. But when I run ImageButton show nothing.
https://gist.github.com/tugnt/98917e0a2293d6cddd2e0e6e21d3d4fb
<Button
android:src="#drawable/ic_speaker"
android:id="#+id/play"
android:layout_margin="#dimen/pd_3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
In your xml,see android:src property is not for button. It's imageview property. So use ImageView instead of Button or set android:background for Button
<ImageView
android:src="#drawable/ic_speaker"
android:id="#+id/play"
android:layout_margin="#dimen/pd_3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Now try this.
Below is your code, in this you have used the android:src="#drawable/ic_speaker" for the button.
<Button
android:src="#drawable/ic_speaker"
android:id="#+id/play"
android:layout_margin="#dimen/pd_3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
But src is for imageview, which doesn't support the button view. So use background instead of src and in the xml preview you cannot see the play button. Have a look at the below code, I have edited the code
<Button
android:background="#drawable/ic_speaker"
android:id="#+id/play"
android:layout_margin="#dimen/pd_3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Use the xml preview to see whether you can see the view or not, which helps to sort put the bug easily and save our time. Hope this is helpful :)
i wish to adjust icons in my application that i'm about to devolp.
this is the link of the tutorial that i'm folowing .
"https://www.youtube.com/watch?v=lkadcYQ6SuY"
this is the example given and created in the tutorial .
now i don't have the reputation yet to post pictures to show you what i want BUT
simple i want arrows for back and forward (custom created) instead of textbuttons
anyone who can help me ... ?
You can use ImageButton, put your icon into drawable folder(if it doesnt exist, create it), and set it to your imageButton
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/yourImgName" />
You can create a simple Button and set its Background for picture.
<Button
android:id="#+id/button"
android:background="#drawable/help"
android:contentDescription="#string/help"
android:gravity="bottom"
android:onClick="showHelp" />
Or you can create ImageButton :
<ImageButton
android:id="#+id/sync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:contentDescription="#string/sync"
android:background="#android:color/transparent"
android:src="#drawable/sync" />
try the below code
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/your_image_name"/>
<TextView
android:id="#+id/first_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<TextView
android:id="#+id/second_textview"
android:layoutbelow="#id/first_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is my first Android Application!" />
<Button
android:id="#+id/first_button"
android:layoutbelow="#id/second_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="And this is a clickable button!" />
I got error when tried to run.
There is a "red" cross at the lines of:
- second
Any idea?
At following two places:
android:layoutbelow="#id/first_textview"
android:layoutbelow="#id/second_textview"
Change layoutbelow to layout_below. Note the use of underscore: _. If you use Ctrl + Spacebar while writing these attributes, eclipse will show you the options available(In case you use eclipse). This way you decrease the chances to such typo mistakes. Hope this helps.
Replace your textview and button line-
android:layoutbelow="#id/first_textview"
with this one-
android:layout_below="#+id/first_textview"
Use "#+id" in giving reference, not the "#id" here and you are missing the "_" in the layoutbelow attribute.
[Accessibility] Missing contentDescription attribute on image
What does this error mean and how can I fix it?
<ImageButton
android:id="#+id/callbannerbuttonpg1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="157dp"
android:background="#null"
android:src="#drawable/callbanner"
android:visibility="invisible" />
Designing for Accessibility
"Defines text that briefly describes content of the view. This property is used primarily for accessibility. Since some views do not have textual representation this attribute can be used for providing such."
And this is not error just a warning. Usage of this attribute is optional.
Add to the imageButton
android:contentDescription="#string/desc"
Just add this:
android:contentDescription="#string/description"
then go to yours Strings.xml and add this:
<string name="description"> YOUR_DESCRIPTION_HERE </string>
as of your code:
<ImageButton
android:id="#+id/callbannerbuttonpg1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="157dp"
android:background="#null"
android:src="#drawable/callbanner"
android:visibility="invisible"
android:contentDescription="#string/description" />
You can ignore such warnings as well by adding this in the imageButton tag :
tools:ignore="contentDescription"
I am trying to replace my previous ugly text button with an imagebutton. However, after changing the XML file with the following ImageButton code, my application won't even start. Why?
<ImageButton
android:layout_height="fill_parent"
android:id="#+id/refresh"
android:src="#drawable/refresh"
/>
specify the layout width..
android:layout_width="wrap_content/*some value ex:50dp*/"
It turned out that I forgot the layout_width attribute. It works now.
<ImageButton
android:layout_height="fill_parent"
android:id="#+id/refresh"
android:src="#drawable/refresh"
android:layout_width="wrap_content"
/>