android左对齐
1. 谁能给我一个关于Android中LineLayout的详细讲解
Android中LinearLayout是线性布局控件,它包含的子控件将以横向或竖向的方式排列,按照相对位置来排列所有的widgets或者其他的containers,超过边界时,某些控件将缺失或消失。因此一个垂直列表的每一行只会有一个widget或者是container,而不管他们有多宽,而一个水平列表将会只有一个行高(高度为最高子控件的高度加上边框高度)。LinearLayout保持其所包含的widget或者是container之间的间隔以及互相对齐(相对一个控件的右对齐、中间对齐或者左对齐)。
1.xml属性
android:baselineAligned:是否允许用户调整它内容的基线。
android:baselineAlignedChildIndex:当一个线性布局与另一个布局是按基线对齐的一部分,它可以指定其内容的基线对齐方式。
android:gravity:指定如何在该对象中放置此对象的内容(x/y坐标值)。
android:orientation:设置它内容的对其方向(横向/竖向)。
2.在LinearLayout中设置排列方式为水平时只有垂直方向的设置是有效的,水平方向的设置是无效的:即left,right,center_horizontal 是不生效的
3.在LinearLayout中设置排列方式为垂直时只有水平方向设置是有效的,垂直方向的设置是无效的是无效的:即top,bottom,center_vertical 是无效的
2. android的TextView里的内容怎么左对齐
默认状态就是左对齐。也可以在配置文件里加个属性android:gravity="left"
3. 一个水平的LinearLayout中 有2个控件,如何让左边的空间 左对齐 右边的控件右对齐
用相对布局RelativeLayout吧,实现这个效果适合用相对布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:onClick="onBack"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"/>
</RelativeLayout>
4. ios和安卓的区别
1. 应用的设备不同:
IOS和安卓最大的区别在于本身所应用的设备不同。IOS系统主要是应用在iPhone、IPad、itouch设备上的操作系统,安卓系统主要是应用在安卓智能手机上的操作系统。
2. 面向人群不同:
IOS系统面向的是中高层收入的人群,有人称它为“高富帅”系统,而安卓系统则是面试中低层的大众人群,有人称它为“屌丝系统”。
3.系统的开放性区别:
安卓拥有自己的开源计划AOSP(Android Open Source Project),只要遵循GPL和Apache Licence 2.0开源协议,那么你就可以使用安卓源代码进行二次开发。而安卓由于源代码开放,自然可玩性也比iOS高。此外,安卓比iOS开放了更多的应用接口API,可以很自然地利用安卓实现很多在iOS上不折腾就没法做的功能。在安卓,可以随心随意地更换输入法,随意用任何浏览器打开链接,随意从任何途经安装程序,随意调用第三方程序分享文件——这些在iOS上不越狱都做不到,即使越狱也未必比安卓做得更好。
4. 系统的安全性区别:
IOS系统是一款比较强大的操作系统,在IOS系统运行的程序不管程序多大都不会造成死机,玩起来非常的流程,而且系统的安全性比较高。
安卓系统是属于代码系统,如果所有的应用程序需要下载下来之后才能玩,系统用久之后会经常出现卡机或者是死机的现象,而且安卓系统还存在恶意的插件在系统上自动运行,系统漏洞多,导致个人资料被盗、系统耗电大,流量消耗大等,系统安全性相对来说比较低。
5. 开发难度不同:
苹果提供完整高效xcode,sdk等开发环境,ios系统一脉相承,ios版本之间的软件通用,即开发一款产品苹果所有设备都能运行。其硬件的强大也让开发变的更加容易。
5. android的TextView里的内容怎么左对齐
TextView里有个属性可以设置的!方法有两个:
在xml中设置属性android:gravity="start";
在代码中这样写 TextView.setGravity(START);
6. 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 :前景
7. android textview 怎么实现跨行左对
没明白你意思。。左对齐?你现在不就是左对齐的么?
还是说你要内容部分左边对齐 意思是后面的行数开始都要在“:”后面对齐?要这样你就分两个TextView就好了啊 一个显示标题 标题右边一个TextView显示内容就可以了。。
如果不是这个意思那默认应该就是坐对齐的,,你要是不放心可以gravity设为left
或者说你现在要实现图片的效果而无法实现? 那你就用一个TextView
然后String title;String content;
SpanableString ss=new SpanableString(title+“:”+content);
ss.setSpan(new ForegroundColorSpan(Color.BLUE),0,title.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(ss);
8. android的TextView里的内容怎么左对齐
这样么
9. android自定义对话框宽不能占满父layout的解决办法有哪些
1.FrameLayout
FrameLayout 是 最简单的一个布局对象。它被定制为你屏幕上的一个空白备用区域,之后你可以在其中填充一个单一对象 —
比如,一张你要发布的图片。所有的子元素将会固定
在屏幕的左上角;你不能为FrameLayout中的一个子元素指定一个位置。后一个子元素将会直接在前一个子元素之上进行覆盖填充,把它们部份或全部挡
住(除非后一个子元素是透明的)。
FrameLayout is the simplest type of layout object. It's basically a blank
space on your screen that you can later fill with a single object — for example,
a picture that you'll swap in and out. All child elements of the FrameLayout are
pinned to the top left corner of the screen; you cannot specify a different
location for a child view. Subsequent child views will simply be drawn over
previous ones, partially or totally obscuring them (unless the newer object is
transparent).
FrameLayout默认填充widget等在左上角,然后后面的控件遮住前面的,比如说有两个TextView,Text内容分别是I am
textview 1 和
I am textview 2 看到的效果会如下:?xml version="1.0" encoding="utf-8"?>
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I am textview 1"
/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I am textview 2"
/>
2.LinearLayout
LinearLayout
以你为它设置的垂直或水平的属性值,来排列所有的子元素。所有的子元素都被堆放在其它元素之后,因此一个垂直列表的每一行只会有一个元素,而不管他们有多
宽,而一个水平列表将会只有一个行高(高度为最高子元素的高度加上边框高度)。LinearLayout保持子元素之间的间隔以及互相对齐(相对一个元素
的右对齐、中间对齐或者左对齐)。
LinearLayout
还支持为单独的子元素指定weight。好处就是允许子元素可以填充屏幕上的剩余空间。这也避免了在一个大屏幕中,一串小对象挤成一堆的情况,而是允许他们放大填充空白。子元素指定一个weight值,剩余的空间就会按这些子元素指定的weight比例分配给这些子元素。默认的weight值为0。例如,如
果有三个文本框,其中两个指定了weight值为1,那么,这两个文本框将等比例地放大,并填满剩余的空间,而第三个文本框不会放大。
下 面的两个窗体采用LinearLayout,包含一组的元素:一个按钮,几个标签,几个文本框。两个窗体都为布局做了一番修饰。文本框的width被设置
为FILL_PARENT;其它元素的width被设置为WRAP_CONTENT。默认的对齐方式为左对齐。左边的窗体没有设置weight(默认为
0);右边的窗体的comments文本框weight被设置为1。如果Name文本框也被设置为1,那么Name和Comments这两个文本框将会有同样的高度。
在 一个水平排列的LinearLayout中,各项按他们的文本基线进行排列(第一列第一行的元素,即最上或最左,被设定为参考基线)。因此,人们在一个窗
体中检索元素时,就不需要七上八下地读元素的文本了。我们可以在layout的XML中设置
android:baselineAligned="false",来关闭这个设置。
LinearLayout aligns all children in a single direction — vertically or
horizontally, depending on how you define the orientation attribute. All
children are stacked one after the other, so a vertical list will only have one
child per row, no matter how wide they are, and a horizontal list will only be
one row high (the height of the tallest child, plus padding). A LinearLayout
respects margins between children and the gravity(right, center, or left
alignment) of each child.
LinearLayout是Android
sdk创建project时的默认Layout,支持两种方式,默认是垂直vertical的线性layout,另一个是水平horizontal方向的线性排列。
效果如下android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I am textview 1"
/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I am textview 2"
/>android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:layout_width="10px"
android:layout_height="fill_parent"
android:text="I am textview 1"
/>
android:layout_width="10px"
android:layout_height="wrap_content"
android:text="I am textview 2"
/>
3.RelativeLayout
RelativeLayout 允
许子元素指定他们相对于其它元素或父元素的位置(通过ID指定)。因此,你可以以右对齐,或上下,或置于屏幕中央的形式来排列两个元素。元素按顺序排列,
因此如果第一个元素在屏幕的中央,那么相对于这个元素的其它元素将以屏幕中央的相对位置来排列。如果使用XML来指定这个layout,在你定义它之前,
被关联的元素必须定义。
这是一个RelativeLayout例子,其中有可视的和不可视的元素。基础的屏幕layout对象是一个RelativeLayout对象。
这 个视图显示了屏幕元素的类名称,下面是每个元素的属性列表。这些属性一部份是由元素直接提供,另一部份是由容器的LayoutParams成员
(RelativeLayout的子类)提供。RelativeLayout参数有
width,height,below,alignTop,toLeft,padding和marginLeft。注意,这些参数中的一部份,其值是相对
于其它子元素而言的,所以才RelativeLayout。这些参数包括toLeft,alignTop和below,用来指定相对于其它元素的左,上和
下的位置。
RelativeLayout lets child views specify their position relative to the
parent view or to each other (specified by ID). So you can align two elements by
right border, or make one below another, centered in the screen, centered left,
and so on. Elements are rendered in the order given, so if the first element is
centered in the screen, other elements aligning themselves to that element will
be aligned relative to screen center. Also, because of this ordering, if using
XML to specify this layout, the element that you will reference (in order to
position other view objects) must be listed in the XML file before you refer to
it from the other views via its reference ID.android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding = "10px"
>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I am textview 1"
/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I am textview 2"
android:layout_marginLeft = "150px"
/>
android:id="@+id/Button02" android:layout_width="wrap_content"
android:text="Ok"
android:layout_height="wrap_content"
android:layout_marginLeft = "240px"
android:layout_marginTop = "40px"
>
android:layout_marginLeft = "160px"
android:layout_marginTop = "40px"
>
4.AbsoluteLayout
AbsoluteLayout 可 以让子元素指定准确的x/y坐标值,并显示在屏幕上。(0,
0)为左上角,当向下或向右移动时,坐标值将变大。AbsoluteLayout没有页边
框,允许元素之间互相重叠(尽管不推荐)。我们通常不推荐使用AbsoluteLayout,除非你有正当理由要使用它,因为它使界面代码太过刚性,以至
于在不同的设备上可能不能很好地工作。
5.TableLayout
TableLayout 将子元素的位置分配到行或列中。android的
一个TableLayout由许多的TableRow组成,每个TableRow都会定义一个row(事实上,你可以定义其它的子对象,这在下面会解释
到)。TableLayout容器不会显示row、cloumns或cell的边框线。每个row拥有0个或多个的cell;每个cell拥有一个
View对象。表格由列和行组成许多的单元格。表格允许单元格为空。单元格不能跨列,这与HTML中的不一样。下图显示了一个TableLayout,图
中的虚线代表不可视的单元格边框。
列可以被隐藏,也可以被设置为伸展的从而填充可利用的屏幕空间,也可以被设置为强制列收缩直到表格匹配屏幕大小。对于更详细信息,可以查看这个类的参考文档。
TableLayout positions its children into rows and columns. TableLayout
containers do not display border lines for their rows, columns, or cells. The
table will have as many columns as the row with the most cells. A table can
leave cells empty, but cells cannot span columns, as they can in HTML.
TableRow objects are the child views of a TableLayout (each TableRow
defines a single row in the table). Each row has zero or more cells, each of
which is defined by any kind of other View. So, the cells of a row may be
composed of a variety of View objects, like ImageView or TextView objects. A
cell may also be a ViewGroup object (for example, you can nest another
TableLayout as a cell).
TableLayout和HTML的基本上类似,还提供TableRow class, 直接等价与比如说要做成一个类似下面的HTML叶面
I am textview1I am textview2
[OK button]
[Cancel button]android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
android:text="I am textview 1" />
android:paddingLeft = "20px"
android:width = "200px"
android:text="I am textview 2"
/>
android:id="@+id/Button02" android:text="Ok"
>
>
10. android 怎样让两个button控件挨在一起,左右对齐 没有距离
Android中两个Button可以使用线性布局LinearLayout来包含。
控件之间的间距有两种设置:
android:layout_margin="10dp" 外边距
android:padding="10dp" 内边距
在Button中将android:layout_margin="0dp" android:padding="0dp"
即将内外两个间距都设置为0即可