线性布局上的一个小错误

来源:互联网 发布:家庭网限制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
原创粉丝点击