线性布局上的一个小错误
来源:互联网 发布:家庭网限制80端口吗 编辑:程序博客网 时间:2024/05/22 09:49
今天做一个demo测试,在一个布局上花费了一点时间
想想自己感到也是可笑,在这里记录下,自己要布局的效果
大致如下
在布局的图中做的效果是
这样的
下面是部分布局代码
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:background="@null" android:text="12-16 16:42" android:textColor="#000000" android:textSize="12sp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="70dp" android:orientation="horizontal" > <ImageView android:layout_width="15dp" android:layout_height="15dp" android:adjustViewBounds="true" android:layout_marginLeft="10dp" android:src="@drawable/ic_launcher" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="35" android:layout_marginRight="10dp" android:textColor="#000000" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="20dp" android:orientation="horizontal" > <ImageView android:layout_width="15dp" android:layout_height="15dp" android:adjustViewBounds="true" android:src="@drawable/ic_launcher" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="评论" android:textColor="#000000" android:textSize="12sp" /> </LinearLayout> </RelativeLayout>感觉也没有什么错误呢为什么移动不过去呢,我这个方面纠结了半天
最后呢看效果图才知道哪里处错误了
效果图:
我又把整体和里面的内容搞混了,我的移动是的线性布局里面的内容
自己把线性布局的宽度设置为match_parent, 想到这里,我把这个宽度
设置wrap_content ,这个问题是自己做布局的时候对于一些宽度没有限制的
总是习惯设置成match_parent,还有的是自己在基础自己还是不够牢固
总是感觉自己什么都会,其实自己太自负了,这个记录希望能提醒自己
最后贴上全部代码,希望对android新手有点帮助
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="wrap_content" android:layout_margin="5dp"><!-- <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:textColor="#ffffff" android:textAppearance="?android:attr/textAppearanceLarge" /> --> <ImageView android:id="@+id/recyclerviewtest" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="center" android:adjustViewBounds="true" android:src="@drawable/ic_launcher"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp"> <com.example.recyclerviewtest.CircleImageView android:layout_width="40dp" android:layout_height="40dp" android:layout_marginLeft="10dp" android:src="@drawable/ic_launcher" app:border_width="0.5dp" app:border_color="#000000"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Baby" android:textColor="#000000" android:layout_marginLeft="60dp"/> <ImageView android:layout_width="wrap_content" android:layout_height="15dp" android:adjustViewBounds="true" android:src="@drawable/ic_launcher" android:layout_marginLeft="90dp"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="60dp" android:layout_marginTop="20dp" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="15dp" android:adjustViewBounds="true" android:src="@drawable/ic_launcher" android:paddingRight="8dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="白领" android:textColor="#000000" android:paddingRight="8dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="发呆ing" android:textColor="#000000" android:paddingRight="8dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="甜美" android:textColor="#000000" android:paddingRight="8dp"/> </LinearLayout> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" android:adjustViewBounds="true" android:layout_alignParentRight="true" android:layout_marginRight="20dp"/> </RelativeLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#330000"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="今天的拿铁特别好喝,心情超级好!" android:textColor="#000000" android:textSize="12sp"/> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:background="@null" android:text="12-16 16:42" android:textColor="#000000" android:textSize="12sp" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="70dp" android:orientation="horizontal" > <ImageView android:layout_width="15dp" android:layout_height="15dp" android:adjustViewBounds="true" android:layout_marginLeft="10dp" android:src="@drawable/ic_launcher" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="35" android:layout_marginRight="10dp" android:textColor="#000000" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="20dp" android:orientation="horizontal" > <ImageView android:layout_width="15dp" android:layout_height="15dp" android:adjustViewBounds="true" android:src="@drawable/ic_launcher" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="评论" android:textColor="#000000" android:textSize="12sp" /> </LinearLayout> </RelativeLayout></LinearLayout>
希望大家给指点下,这个布局怎样。
0 0
- 线性布局上的一个小错误
- 布局时候出现的一个小错误
- 关于Android线性布局中weight属性的一个小发现
- 线性布局小实现——计算器的简单布局
- android学习--adroid线性布局 一个计算器的布局
- 线性布局和相对布局小Demo
- egit的一个小错误
- 沟通的一个小错误
- genymotion的一个小错误
- 一个7.0的小错误
- 关于Android线性布局的一个小小的问题
- css布局的一个小技巧
- 关于div布局的一个小疑惑
- 弹性布局的一个小实例
- 删除sharepoint页面上出现错误的webpart的一个小trick
- windows上运行Pyzip (Z/IP Client)的一个小错误
- 线性布局的详解
- 线性布局的属性
- #include“头文件“的相对路径是相对谁的路径
- 调百度接口,根据地质获取经纬度
- JFinal中的AOP
- ajax与HTML5 history pushState/replaceState实例
- shell脚本打印日志方法
- 线性布局上的一个小错误
- 动态规划(dynamic programming)初步入门
- android UI进阶之实现listview的分页加载
- Oracle 的自治事务 AUTONOMOUS TRANSACTION
- Robot Framework 自动化测试框架安装
- 基于c++11设计一个定时器timer
- PCM data flow - part 2: ASoC data structure
- android中的内外部存储
- 防止js注入