日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

线性布局上的一个小错误

發布時間:2023/11/27 生活经验 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 线性布局上的一个小错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天做一個demo測試,在一個布局上花費了一點時間

想想自己感到也是可笑,在這里記錄下,自己要布局的效果

大致如下


在布局的圖中做的效果是

這樣的


下面是部分布局代碼

 <RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid: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" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="70dp"android:orientation="horizontal" ><ImageViewandroid:layout_width="15dp"android:layout_height="15dp"android:adjustViewBounds="true"android:layout_marginLeft="10dp"android:src="@drawable/ic_launcher" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="35"android:layout_marginRight="10dp"android:textColor="#000000"android:textSize="12sp" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="20dp"android:orientation="horizontal" ><ImageViewandroid:layout_width="15dp"android:layout_height="15dp"android:adjustViewBounds="true"android:src="@drawable/ic_launcher" /><TextViewandroid: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">
<!--     <TextViewandroid: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" /> --><ImageViewandroid:id="@+id/recyclerviewtest"android:layout_width="wrap_content"android:layout_height="wrap_content"android:scaleType="center"android:adjustViewBounds="true"android:src="@drawable/ic_launcher"/><RelativeLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="10dp"> <com.example.recyclerviewtest.CircleImageViewandroid: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"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Baby"android:textColor="#000000"android:layout_marginLeft="60dp"/><ImageViewandroid:layout_width="wrap_content"android:layout_height="15dp"android:adjustViewBounds="true"android:src="@drawable/ic_launcher"android:layout_marginLeft="90dp"/><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="60dp"android:layout_marginTop="20dp"android:orientation="horizontal"><ImageViewandroid:layout_width="wrap_content"android:layout_height="15dp"android:adjustViewBounds="true"android:src="@drawable/ic_launcher"android:paddingRight="8dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="白領"android:textColor="#000000"android:paddingRight="8dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="發呆ing"android:textColor="#000000"android:paddingRight="8dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="甜美"android:textColor="#000000"android:paddingRight="8dp"/></LinearLayout><ImageViewandroid: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><Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:background="#330000"/><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="今天的拿鐵特別好喝,心情超級好!"android:textColor="#000000"android:textSize="12sp"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid: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" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="70dp"android:orientation="horizontal" ><ImageViewandroid:layout_width="15dp"android:layout_height="15dp"android:adjustViewBounds="true"android:layout_marginLeft="10dp"android:src="@drawable/ic_launcher" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="35"android:layout_marginRight="10dp"android:textColor="#000000"android:textSize="12sp" /></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="20dp"android:orientation="horizontal" ><ImageViewandroid:layout_width="15dp"android:layout_height="15dp"android:adjustViewBounds="true"android:src="@drawable/ic_launcher" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="評論"android:textColor="#000000"android:textSize="12sp" /></LinearLayout></RelativeLayout></LinearLayout>

希望大家給指點下,這個布局怎樣。

總結

以上是生活随笔為你收集整理的线性布局上的一个小错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。