Xamarin.Forms Layout Challenges – Social Network App(转载)

  Xamarin.Forms Layout Challenges – Social Network App(转载)

布局示例(一)

原文链接:http://www.kymphillpotts.com/social-network-app-layout-design-in-xamarin-forms/

GitHub链接:https://github.com/kphillpotts/XamarinFormsLayoutChallenges

Youtube视频(英文)在这里:https://www.youtube.com/watch?v=4HlLjTZQzjM

优酷土豆视频(自己录得视频,好像声音挂了.......)在这里:http://v.youku.com/v_show/id_XMjg3ODA5MzUyOA==.html?spm=a2h3j.8428770.3416059.1

图片:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="SocialNetwork.MainPage" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:SocialNetwork" BackgroundColor="White">

    <ScrollView>
        <Grid ColumnSpacing="0" RowSpacing="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="AUTO" />
                <RowDefinition Height="AUTO" />
                <RowDefinition Height="AUTO" />
                <RowDefinition Height="*" />
                <RowDefinition Height="AUTO" />
            </Grid.RowDefinitions>

            <!--  header background  -->
            <Image Aspect="AspectFill" Source="HeaderBackground.png" />
            <Image Aspect="Fill" Source="CurvedMask.png" VerticalOptions="End" />

            <!--  profile image  -->
            <Image HeightRequest="100" HorizontalOptions="Center" Source="ProfilePic.png" TranslationY="50" VerticalOptions="End" WidthRequest="100" />

            <!--  Profile Name  -->
            <StackLayout Grid.Row="1" Padding="0,50,0,00" HorizontalOptions="Center">
                <Label HorizontalTextAlignment="Center" Style="{StaticResource ProfileNameLabel}" Text="Clementine" />
                <Label Margin="0,-5" HorizontalTextAlignment="Center" Style="{StaticResource ProfileTagLabel}" Text="Hipster Coffee Drinker" />
            </StackLayout>

            <!--  Social Stats Section  -->
            <Grid Grid.Row="2" Margin="0,30" ColumnSpacing="0" RowSpacing="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <StackLayout>
                    <Label Style="{StaticResource StatsNumberLabel}" Text="33" />
                    <Label Style="{StaticResource StatsCaptionLabel}" Text="Likes" />
                </StackLayout>

                <StackLayout Grid.Column="1">
                    <Label Style="{StaticResource StatsNumberLabel}" Text="94" />
                    <Label Style="{StaticResource StatsCaptionLabel}" Text="Following" />
                </StackLayout>

                <StackLayout Grid.Column="2">
                    <Label Style="{StaticResource StatsNumberLabel}" Text="957" />
                    <Label Style="{StaticResource StatsCaptionLabel}" Text="Followers" />
                </StackLayout>
            </Grid>

            <!--  profile description  -->
            <ScrollView Grid.Row="3">
                <Label Margin="20,0" HorizontalTextAlignment="Center" Style="{StaticResource MainBodyLabel}" Text="Spicy jalapeno bacon ipsum dolor amet pork loin pork sint sed occaecat swine ham capicola deserunt pork belly frankfurter magna drumstick." />
            </ScrollView>

            <!--  follow button  -->
            <Button Grid.Row="4" Margin="20" Style="{StaticResource FollowButton}" Text="Follow" VerticalOptions="End" />

        </Grid>
    </ScrollView>
</ContentPage>
<?xml version="1.0" encoding="utf-8" ?>
<Application x:Class="SocialNetwork.App" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
    <Application.Resources>
        <!--  Application resource dictionary  -->
        <ResourceDictionary>
            <!--  colors  -->
            <Color x:Key="HeaderTextColor">#585858</Color>
            <Color x:Key="BodyTextColor">#C3C3C3</Color>
            <Color x:Key="ButtonBackgroundColor">#5992FF</Color>

            <!--  font families  -->
            <OnPlatform x:Key="RegularFontFamily" x:TypeArguments="x:String">
                <On Platform="iOS">HelveticaNeue</On>
                <On Platform="Android">sans-serif</On>
            </OnPlatform>

            <OnPlatform x:Key="LightFontFamily" x:TypeArguments="x:String">
                <On Platform="iOS">HelveticaNeue-Light</On>
                <On Platform="Android">sans-serif-light</On>
            </OnPlatform>

            <OnPlatform x:Key="MediumFontFamily" x:TypeArguments="x:String">
                <On Platform="iOS">HelveticaNeue-Medium</On>
                <On Platform="Android">sans-serif-medium</On>
            </OnPlatform>

            <!--  font sizes  -->
            <x:Double x:Key="TitleFontSize">20</x:Double>
            <x:Double x:Key="BodyFontSize">18</x:Double>
            <x:Double x:Key="TagTextFontSize">18</x:Double>
            <x:Double x:Key="StatsNumberFontSize">20</x:Double>
            <x:Double x:Key="StatsCaptionFontSize">16</x:Double>
            <x:Double x:Key="ButtonFontSize">14</x:Double>

            <!--  styles  -->
            <Style x:Key="ProfileNameLabel" TargetType="Label">
                <Setter Property="TextColor" Value="{StaticResource HeaderTextColor}" />
                <Setter Property="FontFamily" Value="{StaticResource MediumFontFamily}" />
                <Setter Property="FontSize" Value="{StaticResource TitleFontSize}" />

            </Style>

            <Style x:Key="ProfileTagLabel" TargetType="Label">
                <Setter Property="TextColor" Value="{StaticResource BodyTextColor}" />
                <Setter Property="FontFamily" Value="{StaticResource RegularFontFamily}" />
                <Setter Property="FontSize" Value="{StaticResource TagTextFontSize}" />
            </Style>

            <Style x:Key="StatsNumberLabel" TargetType="Label">
                <Setter Property="TextColor" Value="{StaticResource HeaderTextColor}" />
                <Setter Property="HorizontalTextAlignment" Value="Center" />
                <Setter Property="FontFamily" Value="{StaticResource LightFontFamily}" />
                <Setter Property="FontSize" Value="{StaticResource StatsNumberFontSize}" />
            </Style>

            <Style x:Key="StatsCaptionLabel" TargetType="Label">
                <Setter Property="TextColor" Value="{StaticResource BodyTextColor}" />
                <Setter Property="Margin" Value="0,-5,0,0" />
                <Setter Property="HorizontalTextAlignment" Value="Center" />
                <Setter Property="FontFamily" Value="{StaticResource LightFontFamily}" />
                <Setter Property="FontSize" Value="{StaticResource StatsCaptionFontSize}" />
            </Style>

            <Style x:Key="MainBodyLabel" TargetType="Label">
                <Setter Property="TextColor" Value="{StaticResource BodyTextColor}" />
                <Setter Property="FontFamily" Value="{StaticResource RegularFontFamily}" />
                <Setter Property="FontSize" Value="{StaticResource BodyFontSize}" />
            </Style>

            <Style x:Key="FollowButton" TargetType="Button">
                <Setter Property="BackgroundColor" Value="{StaticResource ButtonBackgroundColor}" />
                <Setter Property="TextColor" Value="White" />
                <Setter Property="HeightRequest" Value="40" />
                <Setter Property="BorderRadius" Value="20" />
                <Setter Property="FontFamily" Value="{StaticResource MediumFontFamily}" />
                <Setter Property="FontSize" Value="{StaticResource ButtonFontSize}" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

 

时间: 2024-08-08 22:21:43

Xamarin.Forms Layout Challenges – Social Network App(转载)的相关文章

Xamarin.Forms Layout Challenges – Great Places(已全文翻译)

原文地址:https://www.kymphillpotts.com/xamarin-forms-layout-challenges-great-places/ (作者Kym Phillpotts) 项目Github地址:https://github.com/kphillpotts/XamarinFormsLayoutChallenges When your app is all about the images, sometimes you want your images to be her

搞懂Xamarin.Forms布局,看这篇应该就够了吧

Xamarin.Forms 布局介绍 什么是布局?可以简单的理解为,我们通过将布局元素有效的组织起来,让屏幕变成我们想要的样子! 我们通过画图的方式来描述一下Xamarin.Forms的布局. 小节锚点: 布局控件之StackLayout Xamarin.Forms 中可以C#代码进行布局 Xamarin.Forms 的布局方向 边距和填充 八种布局选项 布局控件之Grid 布局控件之AbsoluteLayout 布局控件之ScrollView 布局控件之RelativeLayout 布局控件之

Xamarin.Forms开发APP

Xamarin.Forms+Prism(1)-- 开发准备 准备: 1.VS2017(推荐)或VS2015: 2.JDK 1.8以上: 3.Xamarin.Forms 最新版: 4.Prism 扩展,打开VS的扩展和更新,在联机中,搜索Prism,安装第一个扩展Prism Template Pack: 5.Android SDK,这个下载已经非常快了,国内已经支持Android环境下载. 6.都准备好后,请确保创建一个新的Xamarin.Forms程序后,能正常调试运行,不能调试运行的,请百度或

用Xamarin和Visual Studio编写iOS App

一说开发 iOS app,你立马就会想到苹果的开发语言 Objective C/Swift 和 Xcode.但是,这并不是唯一的选择,我们完全可以使用别的语言和框架. 一种主流的替换方案是 Xamarin,这是一个跨平台框架,允许你开发 iOS.Android 和 OSX.Windows app,它使用的是 C# 和 Visual Studio.最大的好处在于,Xamarin 允许你在 iOS 和 Android app 间共享代码. Xamarin 与其他跨平台框架相比有一个最大的好处:使用

Social Network Analysis的Centrality总结,以及networkx实现EigenCentrality,PageRank和KatzCentrality的对比

本文主要总结近期学习的Social Network Analysis(SNA)中的各种Centrality度量,我暂且翻译为中心度.本文主要是实战,理论方面几乎没有,因为对于庞大的SNA,我可能连门都没有入,但是我觉得这不影响我理解原理后使用他们. 本文为原创,如有不小心侵权的问题出现,请联系本人删除.本文不允许任何形式的转载!!! 一.Centrality的定义 在SNA领域的centrality是用于衡量图中节点的重要度,不同的centrlity算法会对同一节点给出差异很大的centrali

Xamarin.Forms 调用 腾讯地图SDK

Xamarin.Forms研究了好一段时间了,最近一直在学习中,想尝试一下调用其他的SDK,就如腾讯地图SDK(申请容易). 完成此次项目得感谢以下链接: http://www.cnblogs.com/jtang/p/4698496.html 其他文档参考: 腾讯地图SDK(安卓)文档 这里面有详细的使用过程(当然里面的代码是不适用C#的,不过要从这里下载SDK,也有如何申请Key的过程,请参考阅读) Xamarin.Forms自定义每个平台的控件文档 里面有如何根据不同的平台条件下,调用其他页

xamarin.forms模拟rem动态大小值,实现屏幕适配

开发app的时候,比较麻烦的地方,就是处理屏幕适配,比如文字设为12的大小,测试的时候,看得文字挺正常,可是,放到高分辨率设备一看,文字就变得特别小, 怎样实现随着分辨率变大或者变小,所有的size数值,也会等比例变化呢? 首先,在App类,加两个static变量,用来获取屏幕大小 public partial class App : Application { public App () { InitializeComponent(); MainPage = new App1.MainPage

Xamarin.Forms入门-使用 Xamarin.Forms 来创建跨平台的用户界面

Xamarin.Forms 是一个跨平台的.基于原生控件的UI工具包,开发人员可以轻松的创建适用于 Android,iOS 以及 Windows Phone的用户界面.Xamarin.Forms 通过使用平台的原生控件来渲染用户界面,使用 Xamarin.Forms 的 App在外观上与平台完全一致.通过本文您可以快速了解如何使用 Xamarin.Form 来进行应用程序的开发. 简介 Xamarin.Forms可以帮助开发人员快速的构建跨平台的UI,通过一次编码,生成多平台界面.如果你做的工作

Xamarin.Forms教程开发的Xcode的下载安装

Xamarin.Forms教程开发的Xcode的下载安装 Xamarin.Forms教程开发的Xcode的下载安装,Xcode是开发iOS应用程序的图形化开发工具.本节将讲解Xamarin.Forms教程开发的Xcode的下载安装和苹果账号的申请. Xamarin.Forms开发前进行申请苹果账号 苹果账号是苹果公司专门为iOS.Mac.WatchOS开发成员提供的账号,也称开发者账号.有了此账号,开发成员才可以在App Store中进行SDK以及一些常用软件的下载以及安装,Xcode就是其中一