In my Android application I have three tabs in TabHost.
Tab number 2 and 3 loads some data that will take around 4-5 seconds to load. When I click on any of these tabs, the tab disappeared until the data got loaded. Is there any reason for that? How can I handle this disappearing tab ?
One more thing that I should have to mention here is that I am creating Custom Tabs. But no rocket science in custom tabs just follow this links tutorial: http://joshclemm.com/blog/?p=136.
Well I have fixed the problem and find it out what I have done wrong.
The tab_bg_selector.xml file in the example is using android:state_pressed="true" and android:state_focused="true" item states which I have copy/paste in my code as it is. When the Tab is pressed the android:drawable="#android:color/transparent" will make the image transparent until the selected Image will display
So both these item are removed from the .xml file and now it working good :)
Related
I've got two images. I want to do so: when user opens an app with a Light theme - the first image is being used as a background for layouts. When user opens the app with a Dark theme - the second image is being used as a background for layouts.
To solve this problem with text colors, we can just use styles.xml and colors-day/night.xml and one line of code: <item name="android:textColor">#color/textColor</item>
I've tried to the same with images and two styles files: <item name="android:background">#drawable/day</item>
But this feature applies background to each element on a screen, not only to the main layouts.
I know, that I can do it programatically by changing a background with if statements and layout.setBackgroundResource(R.drawable.day/night);
But maybe it can be done with XML as in the case of the text color?
To solve this problem with text colors, we can just use styles.xml and
colors-day/night.xml and one line of code: #color/textColor
You need to do the same thing, but instead of res/values/colors.xml, it should be done on the drawable res/drawable/day
So, you'll have a drawable & drawable-night folders in the res directory each of which should have a unique version of the day image with the same name.
They should look like in Android Studio (Android preview):
And normally use the the attribute name="android:background">#drawable/day</item>
Attached screenshot of netflix app with left side menu I am able to develop a side menu with customized icon and header in it. I want, when the focus comes on header fragment it should expand on top of row fragment, that is not collapsing the row fragment, the same as Netflix and hotstar are doing. How can I achieve it?
unfortunately, the HeaderSupportFragment used in the BrowseSupportFragment is not configurable enough to achieve this kind of design. Leanback is great to build quickly and easily media browser app but when it comes to "complex" design, it's easier to use custom component.
The major difference also here, is that the left menu of the BrowseSupportFragment show each rows header name displayed in the screen (that's why it's called HeaderSupportFragment). Here you want to show different entries like search, home, settings, etc.
To make this kind of view, I would suggest creating your own custom view and use a basic Fragment. I followed this tutorial which can be useful to handle menu open/close animation (I mixed it with a ConstraintLayout to simplify the animation and I made the menu overlap the rest of the screen instead of moving everything.)
See the tutorial: https://medium.com/building-for-android-tv/building-for-android-tv-episode-3-381e041dfec7
I'm having a beginner's problem, blocking my progress, when starting from a scratch application (created with Empty Activity). The initial application builds and runs great showing the Hello World message, but the layout does not show the TextView in the Design nor Blueprint window at all.
If I try to add additional Views, they are also not shown in Design or Blueprint although they do appear properly in the Component Tree and in the Text tab. In the Blueprint, there is just one light blue pixel in the top left - it looks like the Views would be there with zero size. If I click the View in the Component Tree, it shows small icons in the Blueprint but I am not able to drag them (no handles visible).
Android Studio version is 3.1.3, completely up to date, rebooted several times, made a full successful build, "Show Constraints" is on.
Any help would be greatly appreciated to get me moving forward. :)
I have this problem whenever I create a new project in Android Studio, what you have to do is go to the styles.xml file and change the following line:
<style name = "AppTheme" parent = "Theme.AppCompat.Light.DarkActionBar">
And replace it with:
<style name = "AppTheme" parent = "Base.Theme.AppCompat.Light.DarkActionBar">
Chkec this link:
Same issue
Okay, So I just started Android development (I am average at VB.Net, so I understand basic code even if its not in VB). I've made a couple play around apps which used Text-To-Speech, Async Tasks and Reading/Writing files. However, I now wish to make a tabbed Android app.
I started the project in Eclipse Juno and filled in all the details. I then selected (For navigation) the Tabs/Swipe layout. I now have the default code for that layout type (Link to Tabs on developer.android.com - http://developer.android.com/design/building-blocks/tabs.html).
I understand mostly what the default code is doing. The only problem I am having, is determining the individual layout of my Tabs. I wish to have 2 Tabs, 1 in which the user selects an option, and the other, in which an image is shown depending on the selection in Tab 1.
So the question is: How do I create a .xml file in Layout to determine what is shown on the Fragment?
If you want to do this in XML the answer is simple, it can't be done just with XML, you must create a class that's implementing a ActionBar.TabListener.
Than you can override the onTabSelected method in which you can exchange the content.
A proper solution would be:
Use a LinearLayout as root container, and implement two Fragments for each of your Tabs (there you can design an individual XML-layout). Now you can add one fragment initially to the root-container and implement the exchange of the layouts inside the onTabSelected method and you are done.
I'm creating my first app for Android device and I was faced with a challenge... I want to create fixed bottom bar on every screen of my application (something similar to bars from tunein radio).
However I do not know how to make bars which are fixed on every activity (bar do not load when new activity is loaded but is permanent on every app screen). I do not want to <include> my bars in every activity (I've tried this solution but my bars were loading with activity).
Is it possible that this is Activitygroup and only middle activity is changing? If so how can I do that?
PS.
What book or tutorial do you recommend ;-)?
tunein radio bottom and top bar image #1
Use fragments api. It perfectly fits your needs.
Look at ViewFlipper. It lets you manage multiple views. You'd have one activity that would watch your button bar and flip views in response to buttons.