I want to change ActionBar Indicator(the left arrow) and don't want to display the logo
so i setDisplayShowHomeEnabled(false) to make the logo is invisiable,
and setHomeAsUpIndicator(my image) to change the indicator,
but it doesn't work
One way is to not call setDisplayShowHomeEnabled(false). Instead use findViewById() to get the home View, and directly set it to GONE.
View homeView = findViewById(android.R.id.home);
homeView.setVisibility(View.GONE);
Why don't you do this in your Manifest.xml file
android:logo=#null or android:icon=#null
Related
I want my menu items on the BottomNavigationBar to have text-only labels with no icon. Unfortunately, it looks like design_bottom_navigation_item.xml always has a 24x24dp space reserved for the icon, with no publicly-exposed way to set it to gone. And even after getting past that, the label layout is set to a layout_gravity of bottom|center_horizontal, and it doesn't look like there's a way to programatically set layout_gravity to centered.
What is the fastest, easiest way to achieve the goal of a text-only menu item on the bottom nav bar? I'm thinking I can do this by creating a custom version of the item layout, then subclassing BottomNavigationItemView, BottomNavigationMenuView, and BottomNavigationView to specify that custom layout... but that seems like an awful lot of work for one little change. Am I missing something simpler?
dont put iandroid:icon property to your item
Just use the code below. I tried hard to do this easy way but failed.Then I made an alternative. Just use transparent color instead of icon drawble
<item
android:icon="#android:color/transparent"
android:id="#+id/navigation_id"
android:title="title" />
Add this in your dimens file. Then you can add padding according to your navigation view size.
<dimen name="design_bottom_navigation_height"tools:override="true">30dp</dimen>
I'm trying to achieve something like that:
I tried to put a TextView on top of it by changing the elevation, but it falls under the floating button anyway, any suggestion? :S (can surely use an ImageButton that looks like a floating button and put a view on top of that, but I wonder if there is a better way)
Have you tried using the xml:
android:src="#drawable/image" //uses a drawable as a background for your button
Or in java, like this:
fab.setImageDrawable(Drawable);
I don’t know what the real name of this is, but I want to change the top menu for an image or button. Someone can tell me what the name is and how do that in my android aplication?.
something like it!!!
in your menu xml add this in the item tag android:icon="#drawable/youricon"
app:showAsAction="always"
If you mean the custom text, you can add custom vews in your toolbar. The toolbar is just a viewgroup where you can add views inside. See this as an example.
If you mean to add a custom image instead of the back arrow, you can switch it with the toolbar.setNavigationIcon(Drawable drawable) method.
If you want to display the default arrow, then try with this (after setting the toolbar).
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
I am able to customize the Window title bar and its icon by following the below Link :-
http://androidcodesnippetsblog.blogspot.in/2013/03/custom-window-title-bar-in-android.html
But I want to have different title for different activities running in the same project.Is there any way to fix from one particular xml to have title bar and icon for multiple activities.
just Set imageview and textview id in your custom layout and set dynamically its value in particular Activity
ImageView image=(Imageview)getWindow().findViewById(your image view id);
TextView title=(Textview)getWindow().findViewById(your image view id);
set image.setImageResource(...);
and title.settext(title);
Thats it....
Instead of having the theme on your application tag change it to your activity instead. For example:
<activity
android:theme="#style/themeForAcitivy"
android:name="MyActivity">
</activity>
You can also call getActionBar().setCustomView(R.layout.myCustomBar) on each activity to create a custom ActionBar view if that works for you too.
I cannot seem to change the background image of my image button. Heres the code i'm currently trying to use:
ImageButton imgButton = (ImageButton) findViewById(R.id.showSportsButton);
imgButton.setBackgroundResource(R.drawable.tab2_selected);
However this seem to be placing the new image on top of the old image leaving me with 2 images overlapping each other.
Does anyone know why this is??
For solving this question you should implement
imgButton.setImageResource(R.drawable. tab2_selected);
Use this method:
imgButon.setBackground(getActivity().getDrawable(R.drawable.your_icon));
in xml file, <Button> write: android:backgroud="#drawable/your_file"
Make sure you are on same activity. If you are changing background of different activity first create the constructor then use object to change button.
Activity obj= new activity();
obj.imgButton.setBackgroundResource(R.drawable.tab2_selected);
and also check that oncreate() method has void return type if you are using only findviewbyid.