Skip to content

Commit c416177

Browse files
committed
Re-added layout sample
1 parent 3e50313 commit c416177

File tree

88 files changed

+2837
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2837
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories) and given a Build Action of "AndroidAsset".
3+
4+
These files will be deployed with your package and will be accessible using Android's
5+
AssetManager, like this:
6+
7+
public class ReadAsset : Activity
8+
{
9+
protected override void OnCreate (Bundle bundle)
10+
{
11+
base.OnCreate (bundle);
12+
13+
InputStream input = Assets.Open ("my_asset.txt");
14+
}
15+
}
16+
17+
Additionally, some Android functions will automatically load asset files:
18+
19+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
7+
<ProjectGuid>{1FE45A25-2CC5-4CC3-BF01-59ED02E38161}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<RootNamespace>LayoutSamples.Droid</RootNamespace>
10+
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
11+
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
12+
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
13+
<AndroidResgenClass>Resource</AndroidResgenClass>
14+
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
15+
<AndroidApplication>True</AndroidApplication>
16+
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
17+
<AssemblyName>LayoutSamples.Droid</AssemblyName>
18+
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug</OutputPath>
25+
<DefineConstants>DEBUG;</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
<AndroidLinkMode>None</AndroidLinkMode>
29+
<ConsolePause>false</ConsolePause>
30+
</PropertyGroup>
31+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
32+
<DebugType>full</DebugType>
33+
<Optimize>true</Optimize>
34+
<OutputPath>bin\Release</OutputPath>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
38+
<ConsolePause>false</ConsolePause>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<Reference Include="System" />
42+
<Reference Include="System.Xml" />
43+
<Reference Include="System.Core" />
44+
<Reference Include="Mono.Android" />
45+
<Reference Include="Xamarin.Android.Support.v4">
46+
<HintPath>..\packages\Xamarin.Android.Support.v4.22.2.1.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Xamarin.Forms.Platform.Android">
49+
<HintPath>..\packages\Xamarin.Forms.1.5.0.6446\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll</HintPath>
50+
</Reference>
51+
<Reference Include="FormsViewGroup">
52+
<HintPath>..\packages\Xamarin.Forms.1.5.0.6446\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
53+
</Reference>
54+
<Reference Include="Xamarin.Forms.Core">
55+
<HintPath>..\packages\Xamarin.Forms.1.5.0.6446\lib\MonoAndroid10\Xamarin.Forms.Core.dll</HintPath>
56+
</Reference>
57+
<Reference Include="Xamarin.Forms.Xaml">
58+
<HintPath>..\packages\Xamarin.Forms.1.5.0.6446\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
59+
</Reference>
60+
<Reference Include="Xamarin.Forms.Platform">
61+
<HintPath>..\packages\Xamarin.Forms.1.5.0.6446\lib\MonoAndroid10\Xamarin.Forms.Platform.dll</HintPath>
62+
</Reference>
63+
</ItemGroup>
64+
<ItemGroup>
65+
<ProjectReference Include="..\LayoutSamples\LayoutSamples.csproj">
66+
<Project>{A86CFECC-B58E-4E1D-A1CA-ADDF6A3E102C}</Project>
67+
<Name>LayoutSamples</Name>
68+
</ProjectReference>
69+
</ItemGroup>
70+
<ItemGroup>
71+
<Compile Include="MainActivity.cs" />
72+
<Compile Include="Resources\Resource.designer.cs" />
73+
<Compile Include="Properties\AssemblyInfo.cs" />
74+
</ItemGroup>
75+
<ItemGroup>
76+
<None Include="Resources\AboutResources.txt" />
77+
<None Include="Properties\AndroidManifest.xml" />
78+
<None Include="Assets\AboutAssets.txt" />
79+
<None Include="packages.config" />
80+
</ItemGroup>
81+
<ItemGroup>
82+
<Folder Include="Resources\layout\" />
83+
<Folder Include="Resources\values\" />
84+
</ItemGroup>
85+
<ItemGroup>
86+
<AndroidResource Include="Resources\drawable\icon.png" />
87+
<AndroidResource Include="Resources\drawable-hdpi\icon.png" />
88+
<AndroidResource Include="Resources\drawable-xhdpi\icon.png" />
89+
<AndroidResource Include="Resources\drawable-xxhdpi\icon.png" />
90+
</ItemGroup>
91+
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
92+
<Import Project="..\packages\Xamarin.Forms.1.5.0.6446\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.1.5.0.6446\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
93+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
3+
using Android.App;
4+
using Android.Content;
5+
using Android.Content.PM;
6+
using Android.Runtime;
7+
using Android.Views;
8+
using Android.Widget;
9+
using Android.OS;
10+
11+
namespace LayoutSamples.Droid
12+
{
13+
[Activity (Label = "LayoutSamples.Droid", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
14+
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
15+
{
16+
protected override void OnCreate (Bundle bundle)
17+
{
18+
base.OnCreate (bundle);
19+
20+
global::Xamarin.Forms.Forms.Init (this, bundle);
21+
22+
LoadApplication (new App ());
23+
}
24+
}
25+
}
26+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.layoutsamples">
3+
<uses-sdk android:minSdkVersion="15" />
4+
<application android:label="LayoutSamples">
5+
</application>
6+
</manifest>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using Android.App;
4+
5+
// Information about this assembly is defined by the following attributes.
6+
// Change them to the values specific to your project.
7+
8+
[assembly: AssemblyTitle ("LayoutSamples.Droid")]
9+
[assembly: AssemblyDescription ("")]
10+
[assembly: AssemblyConfiguration ("")]
11+
[assembly: AssemblyCompany ("Xamarin")]
12+
[assembly: AssemblyProduct ("")]
13+
[assembly: AssemblyCopyright ("Xamarin")]
14+
[assembly: AssemblyTrademark ("")]
15+
[assembly: AssemblyCulture ("")]
16+
17+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
19+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
20+
21+
[assembly: AssemblyVersion ("1.0.0")]
22+
23+
// The following attributes are used to specify the signing key for the assembly,
24+
// if desired. See the Mono documentation for more information about signing.
25+
26+
//[assembly: AssemblyDelaySign(false)]
27+
//[assembly: AssemblyKeyFile("")]
28+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Images, layout descriptions, binary blobs and string dictionaries can be included
2+
in your application as resource files. Various Android APIs are designed to
3+
operate on the resource IDs instead of dealing with images, strings or binary blobs
4+
directly.
5+
6+
For example, a sample Android app that contains a user interface layout (main.axml),
7+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8+
would keep its resources in the "Resources" directory of the application:
9+
10+
Resources/
11+
drawable/
12+
icon.png
13+
14+
layout/
15+
main.axml
16+
17+
values/
18+
strings.xml
19+
20+
In order to get the build system to recognize Android resources, set the build action to
21+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
22+
instead operate on resource IDs. When you compile an Android application that uses resources,
23+
the build system will package the resources for distribution and generate a class called "R"
24+
(this is an Android convention) that contains the tokens for each one of the resources
25+
included. For example, for the above Resources layout, this is what the R class would expose:
26+
27+
public class R {
28+
public class drawable {
29+
public const int icon = 0x123;
30+
}
31+
32+
public class layout {
33+
public const int main = 0x456;
34+
}
35+
36+
public class strings {
37+
public const int first_string = 0xabc;
38+
public const int second_string = 0xbcd;
39+
}
40+
}
41+
42+
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43+
to reference the layout/main.axml file, or R.strings.first_string to reference the first
44+
string in the dictionary file values/strings.xml.
1.4 KB
Loading
1.75 KB
Loading
2.3 KB
Loading
1.4 KB
Loading

0 commit comments

Comments
 (0)