I am trying to add Tabbar with Tabs on my MAUI application and it's works fine with displaying and navigating between pages. But for some reason I just can't get images to show in the Tab Icon property. I am only getting a round dot. Though I've noticed that if I reference the image wrongly the dot disappears.
I've seen some YouTube videos, I've followed the Microsoft Fundamentals for Shell tabs, I've tried using other icons and extensions, and I've tried adding the Icons to the ShellContent but I am still only getting the round dot.
<Shell
x:Class="MyApp.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyApp">
<TabBar>
<Tab Title="Counter"
Icon="counter.png">
<ShellContent
ContentTemplate="{DataTemplate local:MainPage}"/>
</Tab>
<Tab Title="Log"
Icon="log.png">
<ShellContent
ContentTemplate="{DataTemplate local:Log}"/>
</Tab>
<Tab Title="About"
Icon="about.png">
<ShellContent
ContentTemplate="{DataTemplate local:About}"/>
</Tab>
</TabBar>
</Shell>
The icons work perfectly if I'm using the regular ShellContent without Tab or TabBar.
<Shell
x:Class="MyApp.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyApp"
FlyoutBehavior="Flyout">
<ShellContent
Title="Counter"
ContentTemplate="{DataTemplate local:MainPage}"
Icon="counter.png"
Route="MainPage" />
<ShellContent
Title="Log"
ContentTemplate="{DataTemplate local:Log}"
Icon="log.png"
Route="Log" />
<ShellContent
Title="About"
ContentTemplate="{DataTemplate local:About}"
Icon="about.png"
Route="About" />
</Shell>
The only thing I have'nt tried which is being used on Microsoft Fundamentals is xmlns:local="clr-namespace:MyApp.View" but one of the YouTube videos were also not using this MVVM pattern.
Any suggestions or ideas?
It seems the android doesn't support setting a color image as the tab icon. I have tried your code with the two kinds of image. There is my code:
<TabBar>
<Tab
Title="Home"
Icon="first.png">
<ShellContent ContentTemplate="{DataTemplate local:MainPage}"/>
</Tab>
<Tab Title="NewPage"
Icon="second.png">
<ShellContent ContentTemplate="{DataTemplate local:NewPage1}"/>
</Tab>
</TabBar>
<ShellContent
Title="Home"
Icon="first.png"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
<ShellContent
Title="NewPage"
Icon="second.png"
ContentTemplate="{DataTemplate local:NewPage1}"
Route="NewPage1" />
And the reslut with the color image:
The icon getting a round dot if the image is a color image.
The reslult with the black and white picture:
The icon can show correctly both in the flyoutitem and the tabbar.
Related
I need to remove the border as I marked in the image.
I am using react-native & native-base tabs. I need to remove the bottom border of tabs.
<Tabs>
<Tab heading="Tab1">
<Tab1 />
</Tab>
<Tab heading="Tab2">
<Tab2 />
</Tab>
<Tab heading="Tab3">
<Tab3 />
</Tab>
</Tabs>
I found the solution,
Need to implement ScrollableTab, Then
<ScrollableTab style={{ borderWidth: 0}}>
For everyone still trying to remove the border. This is the problem due to elevation.
Add this to Tabs Tag:
<Tabs tabContainerStyle={{elevation: 0}}>
...
</Tabs>
Try this way <Tabs tabContainerStyle={{ borderBottomWidth: 0 }}>
Try:
<ScrollableTab style={{borderBottomWidth: 0, backgroundColor: 'some_color'}}
/>
or
<TabHeading style={{
backgroundColor: 'some_color',
borderBottomWidth: 0,
}}>
or add below prop/attribute to component:
tabBarUnderlineStyle={{backgroundColor: '#eff2f8'}}
Hi I added a borderWidth: 0px to the styling and this worked for me,
Good Luck!
Wondering if anyone else has run into the following issue.
I've got my App.MainPage wrapped in a navigation page
MainPage = new NavigationPage(new MyPage());
From MyPage I navigate to a user account page which is a TabbedPage
await Navigation.PushAsync(new MyAccountTabbedPage());
and here's the xaml (pretty simple)
<TabbedPage.Children>
<userAccount:SitesTab />
<userAccount:ProjectsTab />
<userAccount:SettingsTab />
</TabbedPage.Children>
Now here's where it gets fun. From within my SitesTab, I need to show a ListView that contains ContextActions
<AbsoluteLayout>
<ListView AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
ItemsSource="{Binding ListItems}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Text="Do Stuff"/>
<MenuItem Text="Delete Stuff" IsDestructive="True"/>
</ViewCell.ContextActions>
<StackLayout>
<Label Text="{Binding .}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</AbsoluteLayout>
The issue I'm running up against is that the context action on Android doesn't cover/replace the NavigationBar, but rather pushes it down and screws everything up.
Before Context
After Context
So what's up here? Has anyone figured out a way around this? That context menu at the top of the page should cover over the NavigationBar instead of push everything down.
turns out I needed the following in my app compat theme
<style name="myActivityTheme" parent="Theme.AppCompat.NoActionBar">
<item name="windowActionModeOverlay">true</item>
</style>
I'm building an app with appcelerator studio for Android system.
So I want to display and customize a ToolBar.
So this is my index.xml layout:
<Alloy>
<Window class="container">
<ActionBar id="actionbar" title="" icon="/images/logo_decipher.png" />
<Menu>
<MenuItem id="item1" title="Settings" />
<MenuItem id="item2" title="Search" />
</Menu>
</Window>
</Alloy>
I want to display my personal Image in this Toolbar. I'm try to use tag icon but not works.
You can use actionbarExtras. https://github.com/ricardoalcocer/actionbarextras/blob/master/documentation/index.md
Ray
I have the following index.xml
<Alloy>
<Window id="container" title="My App">
<View backgroundImage="/myBackground.jpg">
<Label backgroundColor='rgba(0,0,0,0.5)' text="Hello world!"></Label>
</View>
</Window>
</Alloy>
As the documentation says, that should provide me with a Hello World text with a semi-transparent black background. In iOS works fine but it shows a totally transparent background on Android.
I tried putting it in a separate tss file but still the same issue. Any ideas out there?
For some reason android compilations in Titanium don't work well with rgba() syntax for colors. Try the Hex version instead:
<Alloy>
<Window id="container" title="My App">
<View backgroundImage="/myBackground.jpg">
<Label backgroundColor='#50000000' text="Hello world!"></Label>
</View>
</Window>
</Alloy>
In my Flex mobile app, everything is fine on the AIR "adl" emulator running on my computer. But when I deploy the app to my Android phone or tablet, I run into this peculiar problem:
The app works fine when launched in landscape, but when I start it in portrait mode, it just shows a blank white screen. If I rotate it into landscape mode, it renders right away, and I can rotate it back into portrait mode and it still works.
I did some debugging, and it seems that when opened in portrait, the view never gets added to the stage, or even reaches creationComplete. But if I rotate into landscape, it does so immediately.
Any ideas?
Main.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
firstView="views.HomeView">
<fx:Metadata>
[ResourceBundle("resources")]
</fx:Metadata>
<!-- Global CSS styles -->
<fx:Style source="styles/AppStyles.css" />
<fx:Script>
<![CDATA[
// Initialize some vars...
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:ViewNavigatorApplication>
Views/HomeView.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:components="components.*"
creationComplete="init()" menuKeyPressed="handleMenuKeyPressed(event)"
title="...">
<s:states>
<s:State name="portrait" />
<s:State name="landscape" />
</s:states>
<fx:Script source="ViewHandler.as" />
<fx:Script source="HomeViewHandler.as" />
<fx:Style source="../styles/HomeViewStyles.css" />
.....
<s:Label id="resultsHeading" text="{s('Results')}" fontWeight="bold" addedToStage="setResultsHeadingFont()" />
<s:HGroup width="100%" layoutDirection="{s('layoutDirection')}">
<s:Group id="mainResultsGroup" width="90%">
<s:layout.portrait>
<s:VerticalLayout />
</s:layout.portrait>
<s:layout.landscape>
<s:HorizontalLayout gap="{getScaledNumber(100)}" />
</s:layout.landscape>
<s:VGroup>
.....
Here init() never gets called until app is in landscape orientation.
--
UPDATE:
Here's my application.xml:
<?xml version="1.0" encoding="utf-8"?>
<application xmlns="http://ns.adobe.com/air/application/4.0">
<id>com.myapp</id>
<versionNumber>0.1</versionNumber>
<supportedProfiles>mobileDevice</supportedProfiles>
<filename>MyApp</filename>
<name>
<text xml:lang="en">My App</text>
</name>
<android>
<manifestAdditions><![CDATA[<manifest android:installLocation="auto">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch" />
</manifest>]]></manifestAdditions>
</android>
<iPhone>
<InfoAdditions><![CDATA[<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
<key>UIRequiresPersistentWiFi</key>
<string>NO</string>
<key>UIPrerenderedIcon</key>
<true />
<key>UIApplicationExitsOnSuspend</key>
<true />
<key>UIDeviceFamily</key>
<array>
<!-- iPhone support -->
<string>1</string>
<!-- iPad support -->
<!--<string>2</string>-->
</array>]]></InfoAdditions>
<requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
<initialWindow>
<title>My App</title>
<content>MyApp.swf</content>
<visible>true</visible>
<fullScreen>false</fullScreen>
<autoOrients>true</autoOrients>
<!--<aspectRatio>landscape</aspectRatio>-->
<renderMode>cpu</renderMode>
<systemChrome>standard</systemChrome>
</initialWindow>
<icon>
<image48x48>icons/icon_48.png</image48x48>
<image57x57>icons/icon_57.png</image57x57>
<image72x72>icons/icon_72.png</image72x72>
<image96x96>icons/icon_96.png</image96x96>
<image114x114>icons/icon_114.png</image114x114>
<image144x144>icons/icon_144.png</image144x144>
<!--<image512x512>icons/icon_512.png</image512x512>-->
</icon>
<description>
<text xml:lang="en">
</text>
</description>
</application>
BTW I'm using FlashDevelop.
In your [project]-app.xml file, make sure that you have the following line:
<autoOrients>true</autoOrients>
This value defaults to false, so you'll need to make sure you've set it for your app to start properly in both orientations.
I finally got it working, and I can't explain how or why this works.
I have a custom component at the bottom of HomeView.mxml:
<components:MyCustomComp id="customComp" right="0" left="0" bottom="0"
height="40%" maxHeight="700" />
When I set the height property to a number instead of a percentage, everything works fine. But I want a percentage, so instead I leave out the height property in the MXML, and when I initialize the view, I set customComp.percentHeight = 40; and magically it loads perfectly.
Sometimes Flex really perplexes me...
FWIW, the custom component is the last in the View, and is removed and added again as needed from code. When in use, it overlays over the rest of the components in the View. It is a direct child of the view, not inside a Group. Maybe this will help someone else.
UPDATE:
It turns out that the above didn't completely fix it. I ended up needing to remove the maxHeight property as well. Setting maxHeight in AS3 didn't fix it either; I had to remove it completely.