I would like to create swipeable tabs without action bar at its top as shown as in the link. I've used the following lines : setDisplayShowHomeEnabled(false);
setDisplayShowTitleEnabled(false);
Also here is my Layout xml.
Can anyone please help me how I can achieve this.
Your layout should be set up similar to this:
<LinearLayout>
<ToolBar/>
<TabBar/>
<ViewPager/>
</LinearLayout>
Also you should choose a theme without ActionBar (i.E. Theme.AppCompat.Light.NoActionBar) for your application, and not call setSupportActionbar()
Related
I found a description about the difference of transparent and translucent. These are the important parts:
What does translucent mean? If you were writing about a pane of glass,
but that pane of glass was frosty, darkly colored, or very dirty, you
would use translucent.
What does transparent mean? If you were writing about a pane of glass,
and that piece of glass was perfectly clear, you would use
transparent. Something that is transparent allows all light to pass
through it. Clean air and the windshield of a car are transparent.
If you want to understand this deeply then look here.
I want to make a ViewGroup translucent in Android. In a video I found how to make an Activity translucent. What they do is defining the following styles and colors:
<color name="transparent_green_color">#8800ff00</color>
<style name="TranslucentGreen" parent="android:Theme.Translucent">
<item name="android:windowBackground">#color/transparent_green_color</item>
</style>
And then in the manifest the within the application tag they add this new style as a theme:
<application
android:theme="#style/TranslucentGreen"
...>
...
</application>
What I want to do is NOT to make an Activity translucent but to make a ViewGroup translucent.
My layout is structured like this:
<FrameLayout>
<RelativeLayout>
...
</RelativeLayout>
<RelativeLayout>
...
</RelativeLayout>
</FrameLayout>
The second RelativeLayout shall be translucent and the first one shall be visible a bit through the translucent RelativeLayout. How to do that?
Using the Blurry library solved my problem. So if the second ViewGroup (in my case second RelativeLayout) has to be at the top and the first one has to shine through translucent, then you need to call something like:
Blurry.with(context).radius(25).sampling(2).onto(viewGroup);
and then you have the desired effect. For going back to the old view state without translucency you can just use this method:
Blurry.delete(viewGroup)
on the desired view. I like that library because it's very compact.
If you are not able to use external libraries you should maybe start with this Medium article. It works with RenderScript and Bitmap class. Bu It shall be possible to create Bitmaps from ViewGroups.
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 have a hard time finding on how to change the Toolbar title and it's drawable in every and each Activity.
There is something on Android Documentation that states that to minimize APK size. It is recommended to re-used components.
I create a separate layout, and <include layout=""/> to each of my Activities like Help, About , and etc. I also put android:label="Title" on Manifest File.
Toolbar.xml
My Main:
How do I access this included Toolbar DRAWABLE and TITLE in my Activities ?
Update: I removed ActionBar .
You are using Toolbar. So no need to do anything with ActionBar. Just set your Toolbar as supportActionBar. Then set title and icon to your Toolbar.
Use the below code:
mToolbar = (Toolbar)findViewById(R.id.Toolbar);
setSupportActionBar(mToolbar);
setTitle("About");
getSupportActionBar.setIcon(R.id.ic_arrow_back_black_24dp);
And, Remove all your mActionBar codes. Hope this helps.
well you set the support action to your custom toolbar,yet you ignore it and use mActionBar, see where i am going with this? setIcon , and setTitle should all be called relative to your custom toolbar.
I want to customize ActionBarSherlock tabs and tab bar.It is like this.
I want make it like this
You could use a custom view to display the tabs. You could try a 3-arg LinearLayout constructor (added in API 11). By specifying a default style in an XML file, the library tends to leverage the system layout inflator. So, you can also do a similar work around
<LinearLayout style="?attr/actionBarTabStyle" />
And then add the below code
LineraLayout tabView = LayoutInflater.from(context).inflate(R.layout.my_tab, null);
//set your layout params and setCustomView
Here is two links which will help you to customize ABS.
Customize ActionBar TabBar (ActionBarSherlock)
And
How to customize ActionBar in Android (ActionbarSherlock)?
basically you need to make changes in ABS themes and have to play with its drawable.
The problem is the following one : on one of my activities, I needed a custom layout for my action bar, and the only way to do it like needed was to have a transparent ActionBar over my screen. In order to do that, I marked the ActionBar as overlay, and specified the action bar background as transparent. This works when using Android >= 15, but in 14 and below, the ActionBar keeps its bottom border. I tried anything to remove it, with no avail.
Here is a picture to see it more clearly :
On API 14 :
On API 16:
The design is the following : the Action Bar is supposed to be transparent and in overlay mode, and behind it there is a background + the logo
<ImageView
android:id="#+id/action_bar_background"
android:layout_width="match_parent"
android:layout_height="#dimen/action_bar_accueil_total_height"
android:layout_alignParentTop="true"
android:contentDescription="#string/action_bar"
android:scaleType="fitXY"
android:src="#drawable/actionbar_logo_extended" />
<ImageView
android:id="#+id/home_gallica_logo"
android:layout_width="#dimen/largeur_logo_carrousel"
android:layout_height="#dimen/action_bar_accueil_total_height"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="#string/action_bar"
android:src="#drawable/logo_fullcolor" />
Some precisions : I use ABS, but this does not seem to be the source of the problem, as switching to the v7 support library did exactly the same thing.
Do anyone has an idea how to remove this bottom border ?
Following the advice and the test by Luksprog in the comment, I used Theme.Sherlock (instead of Theme.Sherlock.Light) in my action bar for this page, and copied from my old theme the settings I needed. This seems to have resolved the problem, but I'm not completely sure of the source. The only advice I can give to people who are going to see this will be to use Theme.Sherlock.
I've tried to make a simple activity to showcase the behavior but I didn't manage to do it. I used an Activity with the theme Theme.Sherlock:
android:theme="#style/Theme.Sherlock
and to make the overlay(in the onCreate() method):
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); // Window from com.actionbarsherlock.view
//...
setContentView(content);
ActionBar ab = getSupportActionBar();
ab.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
You can hide the action bar at by calling hide() method:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
Or you can set this in your manifest if you want to hide it permanently:
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
>