Android应用界面布局

Android Studio安卓学习笔记(三)Android用户界面的设计布局与组件(一)用户界面布局设计(1)... 当我们创建了一个安卓项目后,我们会发现真正建立一个完善的安卓项目并不是想象的那么容易。其实和设计GUI可视化界面一样,开发安卓也需要考虑很多方面,主要考虑的还是界面布局和需要的组件。 一:Android用户界面布局管理 Android系统按照MVC(模型(model)-视图(view)-控制器(controller))设计模式将应用程序的界面设计与功能控制设计分离,类似于... 阅读详情

Android的应用编写基本都会有一个界面,而Android应用的编写逻辑是遵循MVC模式的,它将界面和控制逻辑是分开的,这样一来,界面编写就和应用的业务逻辑是分开的,更改系统业务逻辑也无需改变前台界面,增强了应用的可维护性,降低长期开发成本。
在Android系统中,应用程序的界面是通过一系列的布局文件实现的。这些布局文件使用XML语法编写,使用标签中的属性指定界面上的视图控件本身的属性和控件之间的关系属性。
Android系统提供了几个非常灵活的布局,但是日常开发中我们最常使用的也就是其中的几种。本文我们重点介绍在Android应用开发中使用频率很高的四种布局:线性布局,相对布局,帧布局,百分比布局。所谓这些布局,其实就是定义了它内部的视图控件的位置怎么排放,约束关系等等。我们可以布局看成是一个盒子,然后我们的button,edittext等控件就是需要放到这些盒子中的物件,同时布局的内部也可以存放其他的布局,也就是说,大盒子的内部可以是小的物件,也可以是小的盒子。
需要强调两点,第一点,在Android应用开发中,布局XML文件不是必须存在的,我们完全可以在java代码中使用代码来构建我们的布局,但是这样的话我们的代码会变得丑陋无比,后期无法维护。这并不是说在代码中控制界面不可取,正确的做法是大部分的布局我们使用xml文件构建,只是在某些特殊的情况我们需要使用代码来控制添加或者删除某些界面上的控件。第二点就是,Android官方提供的android studio工具中的视图化的界面编辑非常方便,但是大家千万不要直接使用这个工具编辑界面,因为在这个界面上妥妥拽拽不能做到精细化设计界面,我们还是需要手动编辑文本,然后使用这个工具进行效果预览就可以了。

线性布局LinearLayout

顾名思义,线性布局的意思就是它内部的控件的位置排列是线性的,要么垂直,要么水平。我们先看一个例子:
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.createchance.uilayouttest.MainActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button 1"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button 2"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button 3"/>
</LinearLayout>

这个布局的效果如下图:
这里写图片描述
这里,我们看到默认的控件位置是水平排放的。我们可以使用android:orientation属性来指定这个线性的水平布局,可以选择的参数是:horizontal(水平,默认值)和vertical(垂直),当我们在LinearLayout标签下增加了android:orientation=”vertical”之后布局就成了下面这样:
这里写图片描述
按照标准来说,每一个控件都应该使用android:layout_width和android:layout_height字段来描述这个控件的宽和高信息,如果没有的话编译会报错(后面我们会看到在百分比布局中,控件可以没有这两个属性)。在线性布局中需要注意的一点就是,如果排列方向是horizontal的话,那么内部的控件的宽度就不能指定为match_parent(铺满父窗口),因为如果指定的话就会是下面这个效果:
这里写图片描述
你会奇怪,怎么第二个和第三个button不见了?是的,他们被button 1挤出去了,你看不见他们了。因为你的button 1的宽度是match_parent,因此它霸占了整个宽度,第二个和第三个button没有地方待了!同理,如果你的布局方向是vertical的话,那么内部的控件的高度就不能是match_parent。
在线性布局中,我们需要注意的一个属性就是android:layout_gravity,这个属性和android:gravity属性看起来有些类似,但是他们之间是有很大的区别的。android:layout_gravity用于制定控件在布局中的对齐方式,而android:gravity用于执行文字或者内容在控件本身中的对齐位置。android:layout_gravity和android:gravity可选值是类似的,但是需要注意的是,当布局的方向是horizontal的时候,只有垂直方向的对齐才是有效的,因为这个时候水平方向的长度是不确定的,如果你新添加一个控件的话水平长度就发生变化了。同理,如果你的布局方向是垂直的,那么只有水平方向的对齐才有效。我们将刚才界面上的三个按钮错开排放:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.createchance.uilayouttest.MainActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:text="Button 1"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="Button 2"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:text="Button 3"/>
</LinearLayout>

效果如下:
这里写图片描述
这里的布局方向是垂直的。
下面,我们介绍另外一个在线性布局中非常重要的属性:android:layout_weight。这个属性可以让我们指定控件在这个布局的某个方向上的占用位置的比重。比如我们想让上面的三个按钮在垂直方向上,均分屏幕高度,我们可以这样:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.createchance.uilayouttest.MainActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="Button 1"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="Button 2"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="Button 3"/>
</LinearLayout>

效果如下:
这里写图片描述
如果我们让三个按钮按照1:2:3的比例分配屏幕高度,我们可以这样:

<Button
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="Button 1"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:text="Button 2"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:text="Button 3"/>

效果如下:
这里写图片描述
可以看到,android:layout_weight的作用就是制定某个控件的占屏比,计算方式就是讲所有的控件的这个属性的值相加,然后讲控件的值除以这个和得出的比值就是占用屏幕的比值。需要说明的是,这里的android:layout_height=”0dp”并不是说这个控件的高度就是0dp,而是说当前的这个属性不指定控件高度,高度有weight属性制定的权重分配,这里的0dp是标准的写法。
有关线性布局中的xml属性参数,可以参考官方文档:https://developer.android.com/reference/android/widget/LinearLayout.html

相对布局RelativeLayout

相对布局也是一种非常常用的界面布局,和线性布局不同的是,这个布局中的控件位置相对随意自由一些。他可以通过相对位置的方式来制定控件的位置,某个控件的位置可以相对于界面边框或者其他的控件而言。正是由于这个原因,相对布局中的属性非常多,但是不用担心,这些属性的命名非常友好,你一眼就能记住并且理解他们的意思。
下面我们给出一个例子:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.createchance.uilayouttest.MainActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 2"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 3"
        android:layout_centerInParent="true"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 4"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 5"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

效果如下:
这里写图片描述
上面的布局代码,我想不解释大家都能看明白吧,属性的命名非常简单易懂。
上面的例子给出的控件相对参照物是布局的边界,同样地,我们也就将这个参照物制定未其中的某一个控件,比如我们这里将这个参照物指定未button 3:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.createchance.uilayouttest.MainActivity">

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 3"
        android:layout_centerInParent="true"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 1"
        android:layout_above="@id/button3"
        android:layout_toLeftOf="@id/button3"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 2"
        android:layout_above="@id/button3"
        android:layout_toRightOf="@id/button3"/>


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 4"
        android:layout_below="@id/button3"
        android:layout_toLeftOf="@id/button3"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 5"
        android:layout_below="@id/button3"
        android:layout_toRightOf="@id/button3"/>

</RelativeLayout>

效果如下:
这里写图片描述
这里需要注意,因为我们将button 3作为其他控件的参照物,因此我们需要做到两件事情:
1. 首先定义button 3,并且给button 3指定一个id,指定参照物的时候需要使用
2. 为了使得我们的界面在任何的手机上都能看起来一致,我们需要将屏幕中参照物相对屏幕的位置固定住,这里button 3的位置仍然是在父布局中水平垂直居中。因为这个参照物固定了,其他参考他的控件位置也就固定了。
相对布局中的xml参数有很多,我们只要理解了相对布局是什么就行,至于全部的参数可以参考官方文档,到时候查阅就可以:https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html。

帧布局FrameLayout

帧布局相对于前两种布局就简单多了,因此他的使用场景也比较少。这种布局没有灵活的定位方式,所有的控件默认都是放在屏幕的左上角。我们看一个例子:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.createchance.uilayouttest.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="This is a string: hello world." />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button 2" />

</FrameLayout>

效果如下:
这里写图片描述
可以看到,上图中的后定义的button将textview遮挡住了,这是因为帧布局中所有的控件默认都是左上角放置的。但是,我们仍然可以通过android:layout_gravity属性来指定控件的位置:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.createchance.uilayouttest.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="This is a string: hello world." />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:text="button 2" />

</FrameLayout>

效果如下:
这里写图片描述
在实际的开发中,我们直接使用帧布局来构建界面的情况不是很多,更多的情况是我们使用这个布局和Fragment配合使用。

百分比布局Percent Layout

前面我们讲述了常用的三种布局,这些布局从Android的第一个正式版本1.0中就开始提供了,并且到现在一直在使用。但是这里面有一个问题,那就是我们在线性布局中可以使用android:layout_weight属性来指定控件占用屏幕的比例大小,但是在剩下的两个布局中我们做不到这一点。比如说,我们想在相对布局中实现让两个按钮平分布局高度的效果,就是比较困难的。这个问题,Android开发团队肯定意识到了,并且及时提供了一种新型的界面布局:百分比布局。这种布局中我们不在需要使用wrap_content, match_parent等方式来指定控件的大小了,而是直接指定控件在布局中占用的百分比,使用十分方便。
由于线性布局本身就可以使用android:layout_weight来实现这样的效果,因此Android只是提供了帧布局和相对布局的功能进行了扩展,提供了PercentFrameLayout和PercentRelativeLayout两种布局。这些布局的实现并不是在framework中的是,而是在Android的support包中的,以便提供不同版本Android系统的兼容性。因此我们需要在android studio中的build.gradle中添加百分比布局的依赖库:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.4.0'
    // 添加百分比布局依赖库
    compile 'com.android.support:percent:23.0.0'
    testCompile 'junit:junit:4.12'
}

布局文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.createchance.uilayouttest.MainActivity">

    <Button
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        android:layout_gravity="top|left"
        android:text="button 1" />

    <Button
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        android:layout_gravity="top|right"
        android:text="button 2" />

    <Button
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        android:layout_gravity="bottom|left"
        android:text="button 3" />

    <Button
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        android:layout_gravity="bottom|right"
        android:text="button 4" />

</android.support.percent.PercentFrameLayout>

效果如下:
这里写图片描述
看到了没?我们很轻松地实现了四个按钮将整个布局平分了!这里需要注意的是,在布局文件中的根标签需要讲百分比布局全部名称写上,因为整个布局是实现在支持包中的。另外需要注意的是,我们需要定义个app的xml命名空间,这样下面我们就可以使用app:layout_widthPercent这样的属性了。
最后,说明一下,如果你的android studio是低于2.2版本的话,那么可能会出现错误:提示说控件没有给出宽和高的定义,这是因为原先系统默认的是每一个控件必须提供宽和高的定义,但是百分比布局出现之后,这个定义可以由app:layout_widthPercent等属性来给出。这个时候你直接忽略这些错误提示即可。

Android应用开发中,界面布局是非常关键的一部分 下面将介绍几种常用的Android界面布局方式,并附上相应的源代码。以上介绍了几种Android界面布局的常用方式,包括线性布局、相对布局、网格布局和帧布局。通过这些不同的布局方式,开发者可以根据实际需求选择合适的布局方式来设计用户界面,提供更好的用户体验。线性布局是Android开发中最基本也是最常用的一种布局方式之一。相对布局是另一种常用的布局方式。帧布局是一种简单的布局方式,它允许子视图叠加在一起,并且只显示最上层的子视图。网格布局提供了一个类似于表格的布局方式,可以按行和列放置子视图。 阅读详情

相关推荐

Android界面布局深入解析与实战应用

在AbsoluteLayout中,子视图的位置是通过layout_x和layout_y属性来指定的,这些属性决定了子视图在布局中的具体位置。通过设置这些属性,开发者能够精确控制每个控件在屏幕上的显示位置。下面是一个简单的AbsoluteLayout的使用示例:<Button<TextView在上述代码中,Button和TextView通过指定layout_x和layout_y属性被放置在AbsoluteLayout的绝对位置上。

weixin_32480007的博客 825

Android开发-基于百度地图API开发仿滴滴出行APP界面的实现

前 言 近年来,由于移动互联网快速的发展以及基于移动设备的APP的普及,移动互联网改变了人们的生活方式。从线上的电子支付到线下的出行,移动互联网是当今社会人们生活不可或缺的一部分,而线下出行的网约车的出现极大便利了人们的出行,虽然它饱受了很大的争议,但不可否认的是网约车的出现是一次大胆创新的尝试。而最早推出网约车的是一家美国硅谷的科技公司推出的Uber网约车打车软件,中文译作“优步”,目前国内做...

_彼岸雨敲窗_的博客 1万+

Android应用开发中的资源管理与界面布局

本文深入探讨了Android应用开发中的资源管理与界面布局技巧。内容涵盖了在Activity状态改变时如何保存和恢复数据,使用BroadcastReceiver响应系统事件,以及如何在后台执行任务以避免ANR错误。同时,文章详细说明了如何通过Service实现应用与后台服务的通信,以及如何使用不同的布局容器来创建直观且功能性强的用户界面。

weixin_33597080的博客 261

安卓layout布局三等分

关于android LinearLayout的比例布局,主要有以下三个属性需要设置:      1,android:layout_width,android:layout_height,android:layout_weight三个值      2,当为水平布局时,android:layout_height=“0dp",当为垂直布局时,android:layout_width="0dp

LY_Dengle的专栏 1万+

Android应用开发:优化平板电脑界面布局

本文详细介绍在Android Developer Fundamentals Course (V2) – Unit 1中关于为平板电脑优化布局的内容。从移除布局约束、调整组件尺寸到使用基线约束和水平扩展按钮,直至最终调整布局方向,为平板电脑用户呈现最佳界面体验。

weixin_28888459的博客 559

HDMI接口技术解析:从基础到应用

本文深入解析HDMI接口技术,从其发展历程、物理结构到传输原理,全面剖析HDMI如何成为影音传输的主流标准。通过对比不同版本的带宽升级和实际应用案例,展示HDMI在4K/8K视频传输中的卓越性能,并分享硬件设计中的实战经验与避坑指南。

weixin_30485379的博客 372

页面布局使按钮按比例显示 ,水平和垂直

&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_paren

FANtastic_Y的博客 1593

突发E层(Es层):短波通信中的“意外惊喜”与“隐形杀手”全解析

本文深入解析了突发E层(Es层)在短波通信中的双重作用,既可能带来超远距离通信的“意外惊喜”,也可能成为通信链路的“隐形杀手”。通过分析Es层的形成机制、时空分布规律及实战应用技巧,帮助通信爱好者与专业人员更好地利用或应对这一电离层现象,提升短波通信的可靠性与效率。

weixin_30443813的博客 825

android布局——按钮等宽比例

android布局常常用到平均分配布局控件,比如用户登录的界面中登录与注册两个按钮,需要按1:1的比例平均分配到布局内容中,TableRow布局可以实现这样的效果。如图-1。需要设置android:layout_weight的权重。如果两个按钮均为android:layout_weight=”1″ 转载于:https://www.cnblogs.com/qsl568/archive/2012/02...

weixin_30709635的博客 1089

Ubuntu 22.04下Nvidia显卡驱动安装全攻略:从PPA源到避坑指南

本文详细介绍了在Ubuntu 22.04系统下安装Nvidia显卡驱动的完整流程,包括PPA源的使用、旧驱动清理、安装后验证及常见问题解决方案。特别针对机器学习开发者和图形设计师,提供了从基础安装到性能调优的全方位指南,帮助用户避免常见安装陷阱并优化GPU性能。

weixin_29213655的博客 382

在银河麒麟V10上部署Atlas 300i Duo:从固件到驱动的一站式踩坑笔记

日期:2025-09-09关键词:鲲鹏920、Atlas 300i Duo、银河麒麟V10、NPU、驱动、固件。

weixin_41544125的博客 2816

四种基本布局————Android studio

标题栏实质上是几个button控件和一个TextView控件。首先新建一个布局title.xml,运用两个按钮键与一个TextView控件做标题栏,找到相应的图标做返回键与确认键。不管有多少布局需要标题栏,只需添加一行:include语句就可以了。之后让控件有相应事件。先在MainActivity同一目录下创建一个TitleLayout继承LinearLayout,给按键设置点击事件。用到的控件的id是自定义控件时的ID。然后在activity_main.xml添加下面几行。

qq_63698991的博客 1394

基于STM32L4XX 、HAL库的TMP144YFFR数字温度传感器驱动应用C语言程序设计

define TMP144_ADDRESS 0x00 // 默认为全局地址,用于单器件或MDA命令。#define TMP144_CMD_READ_TEMP 0x00 // 读取温度寄存器命令。if (temp_raw & 0x800) { // 判断第11位(符号位)

PP_Cottage的博客 91

Android个性名片界面的设计——约束布局的应用

4)选中界面中所有的TextView控件,单击Attributes窗口的搜索框,搜索“text”属性,整体修改TextView控件的字体大小为20sp,颜色为#3F51B5,修改完后,界面如图4所示。5)添加4根横向辅助线,1根纵向辅助线,横向辅助线位置分别为界面垂直方向的15%、30%、45%、60%处,纵向辅助线为界面水平方向的35%,将整个界面分成10个区域,如图5所示。如有错误,可以查看所有控件位置是否完全确定,如果不完全确定,Component Tree区会出现错误提示,如图8所示。

学无止境,止于至善 1033

【Flink on k8s】- 1 - Flink Kubernetes Operator 简介 2023

Flink Kubernetes Operator 可以与 Kubernetes 的其他功能和工具集成,可以帮助用户快速定位和解决问题。Flink Kubernetes Operator可以在Kubernetes上实现高可用性,以确保 Flink 集群的稳定性和可靠性。Flink Kubernetes Operator 可以快速地部署 Flink 集群,而无需手动配置和管理集群。Flink Kubernetes Operator可以将Flink集群与其他应用程序隔离,以避免资源争用和干扰。

欢迎来到我的博客,一起探索代码里的世界! 1348

关于112G和56G PAM4信号的有效回损(ERL)

本文探讨了回波损耗(RL)对高速数字通信系统性能的影响,重点分析了时域信道运行裕度(COM)与频域回波损耗指标的关联性。研究表明,传统频域回波损耗指标在预测系统性能时存在假阳性/假阴性问题,特别是对PAM-4信号系统影响更为显著。通过引入基于时域脉冲响应的有效回波损耗(ERL)指标,并结合判决反馈均衡器(DFE)的补偿效应,可更准确评估系统性能。实验表明,短封装器件虽然频域回波损耗较差,但在实际系统中表现更优。研究提出通过时域门控加权等方法优化ERL计算,为高速互连设计提供了更可靠的性能评估框架。

小孟同学的博客 293

Android开发之应用界面布局Layout

Android开发之应用界面布局Layout 布局,不论在哪个软件开发的过程中无疑都占有很重要的部分,可以想象一下,如过你下载了一个软件,打开一看,按钮和控件的位置布的有想吐感觉,那你还会继续使用这个软件还是换个相似的但布局不错的软件呢?我想答案很明确了吧。 既然布局这么重要

晓伟的专栏 5751

基于OpenCV和Dlib的头部姿态估计详细教程

本文详细介绍了基于OpenCV和Dlib的头部姿态估计方法。通过分析2D人脸特征点与3D头部模型的对应关系,利用PnP(Perspective-n-Point)算法求解头部在三维空间中的姿态。文章首先阐述了坐标系统转换原理,包括世界坐标系、相机坐标系和图像坐标系的转换关系,随后深入讲解了PnP问题的数学表述及求解步骤,并提供了使用Dlib检测68个面部特征点的代码示例。最后介绍了3D通用头部模型的构建方法,包括6点和14点模型的选择,为计算机视觉中的头部姿态估计提供了完整的技术实现方案。

FJN110的博客 338

Android和iPhone应用程序界面布局示例

下图是根据Android和iPhone这两个平台的“生产内容型的应用程序”整理出来的界面布局示例。所对比的4个点,均是两大平台的应用程序常规界面元素。    状态栏: Android和iPhone的状态栏均在屏幕顶端的位置,原因无外乎是人的视觉流程是从上到下的。  Android的状态栏,具有notification的功用,当应用程序有新的通知,在状态栏左侧显示通知图标,向

鹿鸣天涯 1020

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

【Android】相对布局应用-登录界面

使用RelativeLayout实现安卓登录界面,包括跳过按钮、Logo图标、用户名/密码输入框、登录按钮以及其他登录方式图标

阿华的博客 767

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

移动应用开发-第2章Android常见界面布局

界面由布局和控件组成。

2302_78218660的博客 1183

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Android开发--界面布局--约束布局ConstraintLayout的特性与应用

约束布局ConstraintLayout的特性与应用参考资料IDE概述约束条件概览将ConstraintLayout添加到项目中转换布局创建新布局 参考资料 Android开发官方文档–使用 ConstraintLayout 构建自适应界面 IDE Android Studio 概述 通过约束布局可以使用扁平化视图层级结构(无需嵌套或者少嵌套)创建复杂的大型布局。它与 相对布局RelativeLayout 相似,其中所有的视图均根据同级视图与父布局之间的关系进行布局,但具有更高的灵活性,更易于与An

lishen1990的博客 2559

Android与iPhone应用程序界面布局对比

Android与iPhone应用程序界面布局对比 zengzhiyan / 交互设计 / 2010.07.30 13:16 下图是我根据Android和iPhone这两个平台的“生产内容型的应用程序”整理出来的界面布局示例。 所对比的4个点,均是两大平台的应用程序常规界面元素。 状态栏: Android和iPhone的状态栏均在屏幕顶端的位

poyingtingshiliang的博客 788

38、Android编写应用-使用布局编辑器Layout Editor构建界面

在布局编辑器中,您可以通过将界面元素拖动到可视化设计编辑器中(而不是手动编写布局 XML),快速构建布局。设计编辑器支持在不同的 Android 设备和版本上预览布局,并且您可以动态调整布局大小,以确保它能够很好地适应不同的屏幕尺寸。 使用ConstraintLayout构建布局时,布局编辑器的功能尤其强大。前者是一个布局管理器,与 Android 2.3(API 级别 9)及更高版本兼容。 本文简要介绍了布局编辑器。如需详细了解布局基础知识,请参阅布局。 布局编辑器简介 当您打开 XML 布局..

w00347190的博客 3228

android 布局分析,关于Android应用程序界面五大布局的图文分析教程

对于安卓系统应用开发中界面的布局有五大类,分别是LinearLayout(线性布局)、FrameLayout(单帧布局)、AbsoluteLayout(绝对布局)、TablelLayout(表格布局)、RelativeLayout(相对布局)。其中最常用的的是LinearLayout、TablelLayout和RelativeLayout。这些布局都可以嵌套使用。呢么本文就来说说界面布局的基本内容...

weixin_34061121的博客 1897

android应用开发-从设计到实现 2-2 界面布局

界面布局布局涉及到应用界面的整体。布局的层次感和逻辑,可以通过阴影来体现。举个例子。在一张纸当中,增加一条折痕,一个区域就分成了关联性很强的两个区域,将一张纸盖在另一张纸之上,就像是搭台阶一样,上层会在下层投下阴影,这两张纸代表了逻辑不同的两个区域,纸张在z轴的位置,被称作Elevation,很形象的比喻了纸片相对于别的照片被提升了起来。尺寸的度量张纸片之间的距离产生阴影,那么距离用什么来衡量呢?要

不积跬步无以至千里 3951
上一篇: Debian Linux包管理机制
下一篇: Android之ListView详解
createchance
博客等级 码龄15年 156粉丝 90原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值