Bottomnavigation: graphical glitch of the button - java

I am using BottomNavigation for my layout and after I press one button and change the page, the button looks as if I am still pressing it. It helps me if someone can give me a solution.
XML file
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="#menu/bottom_nav_menu"
android:background="?android:attr/windowBackground"/>
The glitch:

Related

Remove arrow icon from expendable card view android

I am using https://github.com/AleSpero/ExpandableCardView library to make an expendable card view. But i don't need the arrow placed in right side.
I also try to find for the attribute or method that can remove this but don't find any one. Please help me to solve this. I will be very grateful. Thanks in advance for your time.
card.setIcon(null);
but it remove only the left icon not the right icon.
Just add this lineandroid:groupIndicator="#null"
<ExpandableListView
android:id="#+id/ev_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="188dp"
android:background="#android:color/white"
android:dividerHeight="0dp"
android:groupIndicator="#null" />
On your MainActivity please use below code
val card : ImageButton = findViewById(R.id.card_arrow)
card.visibility=View.INVISIBL
or remove icon from this xml file expandable_cardview
<ImageButton
android:id="#+id/card_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_alignParentEnd="true"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="#string/expandable_card_view_image_content_description"/>

How to disable the Android text highlighter for buttons?

I'm currently developing an app displaying the default android buttons:
Screenshot
Why is that little blue mark (i don't know the correct name) showing in my app?
This is how I make it visible: I hold the button and then swipe from right to left over the text until the marker appears.
Usually I get that marker in EditText when selecting text - However this is a button and no EditText!
My XML for the button:
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sign in"
android:id="#+id/loginButton"
android:layout_below="#+id/mainLin"
android:layout_centerHorizontal="true"
android:backgroundTint="#2196F3"
android:textColor="#333"
android:textAllCaps="false"
android:layout_gravity="right"
android:enabled="true"
android:layout_marginTop="5dp" />
try in your XML :
android:textIsSelectable="false"
android:longClickable="false"

Custom button programmatically android

I'm creating a list of buttons in Android with the same icon for each of them and then set the text programmatically. So my list has:
ImageView (always the same) + Text (label for the icon which I set programmatically).
How can I create a something like the icon below but where I can change text dinamically?
Thank you!
You can use android:drawableLeft attribute in the TextView. Here's the sample:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/textView"
android:gravity="center_vertical"
android:layout_margin="16dp"
android:drawableLeft="#drawable/ic_launcher"
/>
And the result
I would suggest you using the following
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_text"
android:drawableLeft="#drawable/button_icon"
... />
If you are looking for more customized button, then probably you should learn more about Custom Views:
https://developer.android.com/training/custom-views/index.html
What I understand from your question is that you want to change/set the text of the button programmatically.
for this use the following code in onCreate event:
Button mybutton = (Button) findViewById(R.id.your_button_name);
mybutton.setText("Your Text Here");

PreferenceFragment layout values

I'm creating an app with a main menu, one of these menu items will open up a PreferenceFragment. To create unity within the app I'd like the main menu to look as close to the PreferenceFragment as possible. Basically all the xml values I can use to create menu items that look similar to those in the PreferenceFragment.
Examples of values I need: text size and color (for both title and summary text) and padding values.
I could guess at it but that could take awhile and may not be accurate. There has to be a better way to do it.
Here is what I have so far:
Main Menu (the menu I want to look like the PreferenceFragment): http://i.imgur.com/O5jr14e.png
Preferences (the PreferenceFragment): http://i.imgur.com/YLUnNdX.png
Here are the layout values I have so far the menu item:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="wrap_content" android:id="#+id/menu_item"
android:orientation="vertical" android:layout_weight="1"
android:paddingLeft="10dp">
<TextView android:id="#+id/menu_item_title"
android:textSize="20sp"
android:textColor="#android:color/white"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView android:id="#+id/menu_item_description"
android:textColor="#android:color/darker_gray"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
I am using a ListFragment with a custom ListAdapter to return the above layout with the required String values and display it in the list.
Thanks in advance!
You should use themes and styles if you are looking for the text size and color to be the same throughout the app.
http://developer.android.com/guide/topics/ui/themes.html

Custom Keypad -- How to make these buttons functional?

I have an app that I have almost finished which is a scoreboard app. When the user does a LongClick on the score, currently a dialog box appears which shows an EditText field with an OK and CANCEL button. When the user clicks the EditText field a keypad appears (numbers only) in which the user types in the new score, clicks DONE and then the EditText field shows the new value in the dialog box and when the user clicks OK it saves the entered value to the TextView showing the current score.
The problem is that I feel it is cumbersome. Here is what I would like to happen:
User does a LongClick on score
Keypad appears
User enters new score
User clicks OK
Keypad disappears and value is saved to the TextView updating the current score.
In order to accomplish this, I thought of two things:
I could create a new class extending View -- I'm too new to android to really understand this option.
I could replace the EditText in the dialog with a new XML file which is designed like a keypad.
Option 2: I figured this would probably be the easiest so I have designed the XML Layout and called it keypad.xml. Now when the user does a LongClick the keypad.xml file inflates in a dialog with OK and CANCEL. So far so good. However, I don't know where I should put the code for the button actions.
At first thought, I figured that I could setup some onClick listener which is for ALL BUTTONS in the layout. I figured that all buttons are going to perform the exact same function. Basically, get the text from the button (in this case 0-9) and append it to the TextView which is just above the keypad. Then when the user clicks OK save the TextView in keypad.xml to the current score textview.
Can anyone help point me in the right direction to accomplish this please?
Here is the screenshot of keypad.xml (there is an empty TextView above the numbers):
Here is the XML code:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:columnCount="3" >
<TextView
android:id="#+id/textView1"
android:layout_columnSpan="3"
android:layout_gravity="fill"
android:gravity="right|center_vertical"
android:textSize="24sp" />
<Button android:text="1" />
<Button android:text="2" />
<Button android:text="3" />
<Button android:text="4" />
<Button android:text="5" />
<Button android:text="6" />
<Button android:text="7" />
<Button android:text="8" />
<Button android:text="9" />
<Button
android:layout_columnSpan="3"
android:layout_gravity="fill"
android:gravity="center"
android:text="0" />
This Question has not seemed to prompt a response. In case anyone is looking for an answer to this, I have come up with another solution which isn't exactly the same but works none the less.
Please see this question.

Categories