xamarin android布局练习(1)

xamarin android布局练习,基础非常重要,首先要学习的就是android的布局练习,xamarin也一样,做了几个xamarin android的布局例子,多练习几遍就能学会这个布局,当然有写css的学习这个android的布局很容易入门。

当你看到这篇文章的时候,你应该知道字体图标,下面很多图标都是直接从上面下载的,非常的牛逼,这个字体图标有必要科普一下,这个链接

字体图标下载

首先来看看要做成什么样子的

主要的关键点就是:gravity对其方式,relative布局, linear布局,width,height,orientation方向

代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dedede"
android:id="@+id/relativeLayout">
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#c6c6c6"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请登录"
android:textSize="20sp"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:textColor="#808080" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear1"
android:orientation="vertical"
android:id="@+id/linear2">
<!--相对布局-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:clickable="true"
android:id="@+id/linear3">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/xiaoxi"
android:layout_gravity="center"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/xiaoxi"
android:textColor="@color/test_bg"
android:gravity="center"
android:textSize="30sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#999999" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear2"
android:id="@+id/linear4"
android:orientation="vertical"
android:clickable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/school"
android:layout_gravity="center"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="校园活动"
android:textSize="30sp"
android:textColor="#808080"
android:gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<View
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="#999999" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear4"
android:clickable="true">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img1"
android:src="@drawable/taobao"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="10dp" />
<TextView
android:text="@string/taobao"
android:textColor="@color/test_bg"
android:textSize="30sp"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

xamarin android布局练习(2)

看看效果图2

代码如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/linear1"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/linear2"
android:orientation="vertical"
android:background="#dedede">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="#808080"
android:textSize="20dp"
android:text="如何使用xamarin布局练习"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/relative1">
<ImageView
android:id="@+id/imgCenter"
android:layout_height="100dp"
android:layout_width="100dp"
android:layout_centerInParent="true"
android:src="@drawable/taobao" />
<ImageView
android:id="@+id/imgLeft"
android:layout_alignParentLeft="true"
android:layout_height="100dp"
android:layout_width="100dp"
android:src="@drawable/taobao1" />
<ImageView
android:id="@+id/imgRight"
android:layout_alignParentRight="true"
android:layout_height="100dp"
android:layout_width="100dp"
android:src="@drawable/taobao1" />
</RelativeLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:id="@+id/relative2">
<TextView
android:textColor="#999999"
android:textSize="15dp"
android:text="手机腾讯网"
android:id="@+id/txt1"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<TextView
android:textColor="#999999"
android:textSize="15dp"
android:text="评论 89"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="right" />
</LinearLayout>
<View
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="#808080" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/linear21"
android:orientation="vertical"
android:background="#dedede"
android:layout_marginTop="10dp">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="#808080"
android:textSize="20dp"
android:text="如何使用xamarin布局练习2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/relative11">
<ImageView
android:id="@+id/imgCenter1"
android:layout_height="100dp"
android:layout_width="100dp"
android:layout_centerInParent="true"
android:src="@drawable/taobao" />
<ImageView
android:id="@+id/imgLeft1"
android:layout_alignParentLeft="true"
android:layout_height="100dp"
android:layout_width="100dp"
android:src="@drawable/taobao1" />
<ImageView
android:id="@+id/imgRight1"
android:layout_alignParentRight="true"
android:layout_height="100dp"
android:layout_width="100dp"
android:src="@drawable/taobao1" />
</RelativeLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:id="@+id/relative21">
<TextView
android:textColor="#999999"
android:textSize="15dp"
android:text="手机腾讯网"
android:id="@+id/txt11"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<TextView
android:textColor="#999999"
android:textSize="15dp"
android:text="评论 89"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="right" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

主要的关键点在于:relative布局,

 android:layout_alignParentLeft="true"

这个属性非常重要,在父容器中的对其方式,bool类型的。layout_alignParentLeft="true"在父容器中左对齐

xamarin android布局练习(3)

效果图:

代码如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/relative"
android:background="#dedede">
<ImageView
android:layout_height="64dp"
android:layout_width="64dp"
android:id="@+id/imgCenter"
android:src="@drawable/taobao"
android:layout_centerInParent="true" />
<ImageView
android:layout_height="64dp"
android:layout_width="64dp"
android:id="@+id/imgTop"
android:src="@drawable/wangwang"
android:layout_above="@+id/imgCenter"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_height="64dp"
android:layout_width="64dp"
android:id="@+id/imgRight"
android:src="@drawable/suning"
android:layout_toRightOf="@+id/imgCenter"
android:layout_centerVertical="true" />
<ImageView
android:layout_height="64dp"
android:layout_width="64dp"
android:id="@+id/imgLeft"
android:src="@drawable/suning"
android:layout_toLeftOf="@+id/imgCenter"
android:layout_centerVertical="true" />
<ImageView
android:layout_height="64dp"
android:layout_width="64dp"
android:id="@+id/imgBottom"
android:src="@drawable/jingsong"
android:layout_below="@+id/imgCenter"
android:layout_centerHorizontal="true" />
</RelativeLayout>

关键点在于如何使用relative的各种对其方式

xamarin android布局练习简单的登录(4)

效果如下:
只用了一个linear布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/loginBgColor">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/linear1"
android:orientation="vertical">
<TextView
android:id="@+id/txt"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:layout_marginRight="30dp"
android:layout_gravity="right"
android:text="设备登录"
android:textColor="@color/whiteColor"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txt2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="30dp"
android:textColor="@color/whiteColor"
android:layout_gravity="center"
android:text="LOGO"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<EditText
android:id="@+id/txtUserName"
android:background="@color/whiteColor"
android:hint="请输入用户名"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="20dp"
android:textColor="#000000"
android:paddingLeft="10dp"
android:textCursorDrawable="@null" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#dedede" />
<EditText
android:id="@+id/txtPassword"
android:background="@color/whiteColor"
android:hint="请输入密码1"
android:textCursorDrawable="@null"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="20dp"
android:paddingLeft="10dp"
android:textColor="#000000" />
<Button
android:id="@+id/btnLogin"
android:text="登录"
android:layout_height="50dp"
android:layout_width="match_parent"
android:textColor="@color/whiteColor"
android:background="#2894FF"
android:textSize="20dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_marginTop="20dp" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:id="@+id/linear5">
<CheckBox
android:id="@+id/checkbox_remeberUser"
android:layout_height="30dp"
android:layout_width="30dp"
android:textColor="#336699"
android:textColorHighlight="#336699" />
<TextView
android:id="@+id/remeberUser"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="记住该用户"
android:textColor="#FFFFFF"
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>

xamarin android布局的更多相关文章

  1. Xamarin Android布局文件没有智能提示

    Xamarin Android布局文件没有智能提示 在Visual Studio 2015中,Android项目的Main.axml文件没有智能提示,不便于布局文件的编写.解决办法:(1)从Xamar ...

  2. [置顶] xamarin android 布局尺寸了解

    为了使UI界面在不同大小的移动端显示器上能够正常显示,大家可能都知道使用sp作为字体大小的单位,dp作为其他元素长度的单位. 前几天看了一篇文章关于 App设计规范的,文章用心写的非常好,这里是链接  ...

  3. Xamarin.Android之简单的抽屉布局

    0x01 前言 相信对于用过Android版QQ的,应该都不会陌生它那个向右滑动的菜单(虽说我用的是Lumia) 今天就用Xamarin.Android实现个比较简单的抽屉布局.下面直接进正题. 0x ...

  4. Xamarin.Android之布局文件智能提示问题

    一.前言 看到有人问关于xamarin.android的布局没智能提示问题(VS 2015),当然,写布局这东西没提示这是一件相对痛苦的事 ,所以这里就提供一个解决的方案! 二.解决方案 想要智能提示 ...

  5. Xamarin Android 之起始篇

    序言: 在博客园注册了已经有2年多了,快三年了.从开始学习这一行开始就在博客园注册了这个账号.至今也还没有写过一篇随笔,大多时候都是在园子里头潜水,看大牛写的文章,学习. 写博客不为啥,就是自己对自己 ...

  6. [译]:Xamarin.Android开发入门——Hello,Android Multiscreen深入理解

    原文链接:Hello, Android Multiscreen_DeepDive. 译文链接:Xamarin.Android开发入门--Hello,Android Multiscreen深入理解. 本 ...

  7. [译]:Xamarin.Android开发入门——Hello,Android Multiscreen快速上手

    原文链接:Hello, Android Multiscreen Quickstart. 译文链接:Hello,Android Multiscreen快速上手 本部分介绍利用Xamarin.Androi ...

  8. [译]:Xamarin.Android开发入门——Hello,Android深入理解

    返回索引目录 原文链接:Hello, Android_DeepDive. 译文链接:Xamarin.Android开发入门--Hello,Android深入理解 本部分介绍利用Xamarin开发And ...

  9. Xamarin.Android之引导页的简单制作

    0x01 前言 对于现在大部分的APP,第一次打开刚安装或更新安装的APP都会有几个引导界面,通常这几个引导页是告诉用户 APP有些什么功能或者修改了什么bug.新增了什么功能等等等. 下面就用Xam ...

随机推荐

  1. 轻松学习 JavaScript——第 6 部分:JavaScript 箭头函数

    JavaScript箭头函数是ECMAScript 6中引入的编写函数表达式的一种简便方法.通常,在JavaScript中,可以通过两种方式创建函数: 函数语句. 函数表达式. 可以如下所示创建函数语 ...

  2. java中的static和final关键字

    一:static 1)修饰成员变量: static关键字可以修饰成员变量,它所修饰的成员变量不属于对象的数据结构,而是属于类的变量,通常通过类名来引用static成员. 当创建对象后,成员变量是存储在 ...

  3. eric6 中 designer 无法启动的解决办法

    1.安装环境:win10+python3.6+Eric6 2.问题:使用 pip install PyQt5 安装 PyQt5.9 版本后,发现 Eric6 中无法打开 designer.exe 工具 ...

  4. MySQL 性能优化的最佳20多条经验分享(三)(转)

    16. 垂直分割 "垂直分割"是一种把数据库中的表按列变成几张表的方法,这样可以降低表的复杂度和字段的数目,从而达到优化的目的.(以前,在银行做过项目,见过一张表有100多个字段, ...

  5. fiddler+android抓包工具配置使用

    今天临时增加一个工作,手机需要抓包,查看了不同的抓包工具,最后确定使用fiddler抓包工具进行操作,这里以android为例记录一下工具的配置和使用操作. fiddler的安装 网上有很多fiddl ...

  6. Oracle基础知识整理

    Oracle以dba身份登陆 sqlplus / as sysdba;  表空间操作  创建用户以及授权操作 --创建表 create table teacher ( tNo number(4) no ...

  7. 认知服务调用如何使用图片的DataURL

    说明: Data URL给了我们一种很巧妙的将图片"嵌入"到HTML中的方法.跟传统的用img标记将服务器上的图片引用到页面中的方式不一样,在Data URL协议中,图片被转换成b ...

  8. ssh服务、密钥登陆配置

    环境内核信息: [root@zabbix-01 ~]# uname -a Linux lodboyedu-01 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:2 ...

  9. 基于winpcap的以太网流量分析器(java)

    开发工具 IDE:eclipse -neon JDK:1.8 OS:Win10-64bit 主要功能 1.要求完成一个基于Winpcap的网络流量统计分析系统,具有易用.美观的界面. 2.完成局域网( ...

  10. linux shell 推断文件或目录是否真的存在

    #推断文件或目录是否存在 filepath=/data/test.txt folderpath=/data/qtech #推断文件是否存在 if [ -f "$file" ] th ...