当前位置:首页 » 安卓系统 » androidbutton对齐

androidbutton对齐

发布时间: 2022-05-31 02:10:34

‘壹’ android 怎样让两个button控件挨在一起,左右对齐 没有距离

Android中两个Button可以使用线性布局LinearLayout来包含。

控件之间的间距有两种设置:

  1. android:layout_margin="10dp" 外边距

  2. android:padding="10dp" 内边距

在Button中将android:layout_margin="0dp" android:padding="0dp"

即将内外两个间距都设置为0即可

‘贰’ android按钮等控件如何设置字显示两端对齐,解决了吗,能分享下方法吗

你的设计图呢?
如果不是固定的宽度的话设置:android:layout_width="wrap_content"
就可以了啊。

‘叁’ android编程怎么让控件的“右边”对齐在屏幕的中心

<?xml version="1.0" encoding="utf-8"?>
<!--
android:layout_above 将该控件的底部至于给定ID的控件之上
android:layout_below 将该控件的顶部至于给定ID的控件之下
android:layout_toLeftOf 将该控件的右边缘和给定ID的控件的左边缘对齐
android:layout_toRightOf 将该控件的左边缘和给定ID的控件的右边缘对齐

android:layout_alignBaseline 该控件的baseline和给定ID的控件的baseline对齐
android:layout_alignBottom 将该控件的底部边缘与给定ID控件的底部边缘
android:layout_alignLeft 将该控件的左边缘与给定ID控件的左边缘对齐
android:layout_alignRight 将该控件的右边缘与给定ID控件的右边缘对齐
android:layout_alignTop 将给定控件的顶部边缘与给定ID控件的顶部对齐

android:alignParentBottom 如果该值为true,则将该控件的底部和父控件的底部对齐
android:layout_alignParentLeft 如果该值为true,则将该控件的左边与父控件的左边对齐
android:layout_alignParentRight 如果该值为true,则将该控件的右边与父控件的右边对齐
android:layout_alignParentTop 如果该值为true,则将空间的顶部与父控件的顶部对齐

android:layout_centerHorizontal 如果值为真,该控件将被至于水平方向的中央
android:layout_centerInParent 如果值为真,该控件将被至于父控件水平方向和垂直方向的中央
android:layout_centerVertical 如果值为真,该控件将被至于垂直方向的中央

android:padding和android:layout_margin 通俗的理解 Padding 为内边框,Margin 为外边框
android:padding和android:layout_margin的区别,其实概念很简单,padding是站在父view的角度描述问题,它规定它里面的内容必须与这个父view边界的距离。margin则是站在自己的角度描述问题,规定自己和其他(上下左右)的view之间的距离,如果同一级只有一个view,那么它的效果基本上就和padding一样了。

android:layout_gravity="center"
android:gravity属性是对该view 内容的限定.比如一个button 上面的text. 你可以设置该text 在view的靠左,靠右等位置..
android:layout_gravity是用来设置该view相对与起父view 的位置.比如一个button 在linearlayout里,你想把该button放在靠左靠右等位置就可以通过该属性设置.

‘肆’ android中怎样把一个button按钮放到屏幕底部

<?xml version="1.0" encoding="utf-8"?>
<!--
android:layout_above 将该控件的底部至于给定ID的控件之上
android:layout_below 将该控件的顶部至于给定ID的控件之下
android:layout_toLeftOf 将该控件的右边缘和给定ID的控件的左边缘对齐
android:layout_toRightOf 将该控件的左边缘和给定ID的控件的右边缘对齐

android:layout_alignBaseline 该控件的baseline和给定ID的控件的baseline对齐
android:layout_alignBottom 将该控件的底部边缘与给定ID控件的底部边缘
android:layout_alignLeft 将该控件的左边缘与给定ID控件的左边缘对齐
android:layout_alignRight 将该控件的右边缘与给定ID控件的右边缘对齐
android:layout_alignTop 将给定控件的顶部边缘与给定ID控件的顶部对齐

android:alignParentBottom 如果该值为true,则将该控件的底部和父控件的底部对齐
android:layout_alignParentLeft 如果该值为true,则将该控件的左边与父控件的左边对齐
android:layout_alignParentRight 如果该值为true,则将该控件的右边与父控件的右边对齐
android:layout_alignParentTop 如果该值为true,则将空间的顶部与父控件的顶部对齐

android:layout_centerHorizontal 如果值为真,该控件将被至于水平方向的中央
android:layout_centerInParent 如果值为真,该控件将被至于父控件水平方向和垂直方向的中央
android:layout_centerVertical 如果值为真,该控件将被至于垂直方向的中央
-->

够详细了把

‘伍’ 安卓编程怎么使按钮右对齐

安卓编程使按钮右对齐解决思路如下:

(1)可以设置按钮宽度会充满整个屏幕。
(2)使按钮中的文字右对齐。
这样就ok啦~
实现方法:
<Button
android:id="@+id/btnAppMore"
android:layout_width="fill_parent"//设置宽度跟屏幕一样大
android:layout_height="wrap_content"
android:text="详细信息>>"
android:gravity="right"//右对齐
android:background="@android:color/transparent"
/>

‘陆’ Android LinearLayout布局中的对齐问题

如果使用组件对齐方式,比较简单的是RelativeLayout,linearLayout必须设置android:layout_weight,这个属性是说它在布局中所占的比例,关键是他是横向的,不好用,除了某些特殊情况。

‘柒’ Android XML布局中,怎么设置两个Button按钮在同一行显示

Relativelayout:可以在button2的属性里设置android:layout_toRightOf ,将button2的左边缘和button1的的右边缘对齐;或者设置android:layout_toLeftOf ,将button2右边缘和button1的左边缘对齐,自己选择;
LinearLayout:可以设置其属性android:orientation="horizontal",即垂直方向,也可以是button1和button2显示在一行,至于哪个在左哪个在右凭你的喜好了,哈哈

‘捌’ 如何让按钮与textview里的文字顶部对齐

在这两个控件外边套个RelativeLayout
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview显示的text"
android:layout_centerVertical="true" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/textview1"
android:text="button显示的text"
android:layout_centerVertical="true"/>
</RelativeLayout>
本回答由提问者推荐

‘玖’ android代码如何快速对齐

1,android:orientation
布局方向。horizontal是让所有的子元素按水平方向从左到右排列,
vertical是让所有的子元素按竖直方向从上到下排列。

2,android:gravity 与
android:layout_gravity的区别android:gravity是指定本元素的子元素相对它的对齐方式。

android:layout_gravity是指定本元素相对它的父元素的对齐方式。
例如:

下面这里的linearlayout的android:gravity设为right,有两个子元素Button01和Button02。

java代码:
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:gravity=”right”
>
<Button android:text=”button01″ android:id=”@+id/Button01″ android:layout_width=”wrap_content” android:layout_height=”wrap_content”></Button>
<Button android:text=”button02″ android:id=”@+id/Button02″ android:layout_width=”wrap_content” android:layout_height=”wrap_content”></Button>
</LinearLayout>
这个main.xml里的LinearLayout也是有两个子元素Button01和Button02。Button01的android:layout_gravity设为”left”,Button02的
android:layout_gravity设为”right”
java代码:
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>
<Button
android:layout_gravity=”left”
android:text=”button01″
android:id=”@+id/Button01″
android:layout_width=”wrap_content” a
ndroid:layout_height=”wrap_content”></Button>
<Button
android:layout_gravity=”right”
android:text=”button02″
android:id=”@+id/Button02″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”>
</Button>
</LinearLayout>
FameLayout布局

FrameLayout是最简单的一个布局对象。它被定制为你屏幕上的一个空白备用区域,之后你可以在其中填充一个单一对象—比如,一张你要发布的图片。所有的子元素将会固定在屏幕的左上角;你不能为FrameLayout中的一个子元素指定一个位置。后一个子元素将会直接在前一个子元素之上进行覆盖填充,把它们部份或全部挡住(除非后
一个子元素是透明的)。xml属性

1,用xml文件来定义界面,然后Activity的setContentView方法根据xml文件里的定义来创建真正的控件对象。好比说xml文件是设计图纸,setContentView是生产机器,它依照图纸生产出各种各样的杯具和洗具。

2,FrameLayout的xml属性来自三个地方:继承下来的,嵌套类定义的,自身类定义的。

3,具的属性可查阅官方文档。下面是刚才遇到的几个属性。
java代码:
android:id
//这个xml属性是继承自android.view类的xml属性。它为framelayout提供一个唯一识别符号,之后,程序要用到它时可以用View.findViewById() 或Activity.findViewById()来找到它。
android:layout_width: 布局宽
android:layout_height: 布局高
//它们的取值是fill_parent或wrap_content。
fill_parent :在x轴或则y轴上充满父容器的空间。
wrap_content :framelayout里的元素有多少宽高就多少宽高,
//这两个属性都是定义在android.widget.FrameLayout的嵌套类android.widget.FrameLayout.LayoutParams里。
android:background:背景
android:foreground :前景

‘拾’ Android如何在一个界面里布局4个按钮 分为2行2列 与屏幕上下、水平居中对齐

这个实现的方法很多,我简单说一个吧,最外层一个线性布局,设置内部在父容器中居中,然后里面一个表格布局就可以,或者网格布局也行。还可以用两个线性布局,每个布局里面有两个按钮,并且设置 它为水平居中,就可以了

热点内容
联通的设置的初始密码是多少 发布:2025-08-20 23:33:48 浏览:738
vc6编译操作 发布:2025-08-20 23:16:14 浏览:869
时统服务器搭建 发布:2025-08-20 23:15:58 浏览:907
c语言单字符 发布:2025-08-20 23:15:12 浏览:70
outlook发送服务器地址在哪里 发布:2025-08-20 23:06:13 浏览:1000
c语言培训心得 发布:2025-08-20 23:02:20 浏览:46
如何打开raw服务器镜像 发布:2025-08-20 22:48:13 浏览:76
1分钟造解压神器 发布:2025-08-20 22:46:28 浏览:378
云服务器搭建spark 发布:2025-08-20 22:41:19 浏览:36
好用免费云服务器 发布:2025-08-20 22:16:44 浏览:609