committed by
GitHub
9 changed files with 5 additions and 356 deletions
@ -1,79 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0-android</TargetFramework> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<OutputType>Exe</OutputType> |
|||
<Nullable>enable</Nullable> |
|||
<ApplicationId>com.Avalonia.AndroidTestApplication</ApplicationId> |
|||
<ApplicationVersion>1</ApplicationVersion> |
|||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> |
|||
<AndroidPackageFormat>apk</AndroidPackageFormat> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
<DebugType>portable</DebugType> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<AndroidResource Include="..\..\..\build\Assets\Icon.png"> |
|||
<Link>Resources\drawable\Icon.png</Link> |
|||
</AndroidResource> |
|||
</ItemGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''"> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<RunAOTCompilation>True</RunAOTCompilation> |
|||
<EnableLLVM>True</EnableLLVM> |
|||
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<BundleAssemblies>True</BundleAssemblies> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
|||
<BundleAssemblies>True</BundleAssemblies> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> |
|||
<ProjectReference Include="..\Avalonia.Android\Avalonia.Android.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj"> |
|||
<Project>{7b92af71-6287-4693-9dcb-bd5b6e927e23}</Project> |
|||
<Name>Avalonia.Android</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|||
<Name>Avalonia.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|||
<Name>Avalonia.Themes.Default</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Skia\Avalonia.Skia\Avalonia.Skia.csproj"> |
|||
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project> |
|||
<Name>Avalonia.Skia</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> |
|||
<Import Project="..\..\..\build\Base.props" /> |
|||
<Import Project="..\..\..\build\Rx.props" /> |
|||
<Import Project="..\..\..\build\System.Memory.props" /> |
|||
<Import Project="..\..\..\build\AndroidWorkarounds.props" /> |
|||
<Import Project="..\..\..\build\LegacyProject.targets" /> |
|||
</Project> |
|||
@ -1,104 +0,0 @@ |
|||
using System; |
|||
using Android.App; |
|||
using Android.Content.PM; |
|||
using Avalonia.Android; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Input.TextInput; |
|||
using Avalonia.Markup.Xaml; |
|||
using Avalonia.Media; |
|||
using Avalonia.Styling; |
|||
using Avalonia.Themes.Default; |
|||
|
|||
namespace Avalonia.AndroidTestApplication |
|||
{ |
|||
[Activity(Label = "Main", |
|||
MainLauncher = true, |
|||
Icon = "@drawable/icon", |
|||
Theme = "@style/Theme.AppCompat.NoActionBar", |
|||
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, |
|||
LaunchMode = LaunchMode.SingleInstance/*, |
|||
ScreenOrientation = ScreenOrientation.Landscape*/)] |
|||
public class MainActivity : AvaloniaActivity<App> |
|||
{ |
|||
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) |
|||
{ |
|||
return base.CustomizeAppBuilder(builder); |
|||
} |
|||
} |
|||
|
|||
public class App : Application |
|||
{ |
|||
public override void Initialize() |
|||
{ |
|||
Styles.Add(new SimpleTheme(new Uri("avares://Avalonia.AndroidTestApplication"))); |
|||
} |
|||
|
|||
public override void OnFrameworkInitializationCompleted() |
|||
{ |
|||
if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime) |
|||
{ |
|||
singleViewLifetime.MainView = CreateSimpleWindow(); |
|||
} |
|||
|
|||
base.OnFrameworkInitializationCompleted(); |
|||
} |
|||
|
|||
// This provides a simple UI tree for testing input handling, drawing, etc
|
|||
public static ContentControl CreateSimpleWindow() |
|||
{ |
|||
ContentControl window = new ContentControl() |
|||
{ |
|||
Background = Brushes.Red, |
|||
Content = new StackPanel |
|||
{ |
|||
Margin = new Thickness(30), |
|||
Background = Brushes.Yellow, |
|||
Children = |
|||
{ |
|||
new TextBlock |
|||
{ |
|||
Text = "TEXT BLOCK", |
|||
Width = 300, |
|||
Height = 40, |
|||
Background = Brushes.White, |
|||
Foreground = Brushes.Black |
|||
}, |
|||
|
|||
new Button |
|||
{ |
|||
Content = "BUTTON", |
|||
Width = 150, |
|||
Height = 40, |
|||
Background = Brushes.LightGreen, |
|||
Foreground = Brushes.Black |
|||
}, |
|||
|
|||
CreateTextBox(TextInputContentType.Normal), |
|||
CreateTextBox(TextInputContentType.Password), |
|||
CreateTextBox(TextInputContentType.Email), |
|||
CreateTextBox(TextInputContentType.Url), |
|||
CreateTextBox(TextInputContentType.Digits), |
|||
CreateTextBox(TextInputContentType.Number), |
|||
} |
|||
} |
|||
}; |
|||
|
|||
return window; |
|||
} |
|||
|
|||
private static TextBox CreateTextBox(TextInputContentType contentType) |
|||
{ |
|||
var textBox = new TextBox() |
|||
{ |
|||
Margin = new Thickness(20, 10), |
|||
Watermark = contentType.ToString(), |
|||
BorderThickness = new Thickness(3), |
|||
FontSize = 20, |
|||
[TextInputOptions.ContentTypeProperty] = contentType |
|||
}; |
|||
|
|||
return textBox; |
|||
} |
|||
} |
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<application android:label="Avalonia.AndroidTestApplication" android:icon="@drawable/Icon" android:hardwareAccelerated="true"></application> |
|||
</manifest> |
|||
@ -1,50 +0,0 @@ |
|||
Images, layout descriptions, binary blobs and string dictionaries can be included |
|||
in your application as resource files. Various Android APIs are designed to |
|||
operate on the resource IDs instead of dealing with images, strings or binary blobs |
|||
directly. |
|||
|
|||
For example, a sample Android app that contains a user interface layout (main.xml), |
|||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) |
|||
would keep its resources in the "Resources" directory of the application: |
|||
|
|||
Resources/ |
|||
drawable-hdpi/ |
|||
icon.png |
|||
|
|||
drawable-ldpi/ |
|||
icon.png |
|||
|
|||
drawable-mdpi/ |
|||
icon.png |
|||
|
|||
layout/ |
|||
main.xml |
|||
|
|||
values/ |
|||
strings.xml |
|||
|
|||
In order to get the build system to recognize Android resources, set the build action to |
|||
"AndroidResource". The native Android APIs do not operate directly with filenames, but |
|||
instead operate on resource IDs. When you compile an Android application that uses resources, |
|||
the build system will package the resources for distribution and generate a class called |
|||
"Resource" that contains the tokens for each one of the resources included. For example, |
|||
for the above Resources layout, this is what the Resource class would expose: |
|||
|
|||
public class Resource { |
|||
public class drawable { |
|||
public const int icon = 0x123; |
|||
} |
|||
|
|||
public class layout { |
|||
public const int main = 0x456; |
|||
} |
|||
|
|||
public class strings { |
|||
public const int first_string = 0xabc; |
|||
public const int second_string = 0xbcd; |
|||
} |
|||
} |
|||
|
|||
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main |
|||
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first |
|||
string in the dictionary file values/strings.xml. |
|||
|
Before Width: | Height: | Size: 4.0 KiB |
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
|
|||
<resources> |
|||
<string name="Hello">Hello World, Click Me!</string> |
|||
<string name="ApplicationName">Avalonia.AndroidTestApplication</string> |
|||
</resources> |
|||
Loading…
Reference in new issue