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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android xml正方形,使用Android Constraintlayout创建一排均匀分布的正方形

發(fā)布時間:2023/12/10 Android 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android xml正方形,使用Android Constraintlayout创建一排均匀分布的正方形 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我正在努力創(chuàng)建一個由均勻分布的正方形鏈組成的布局,這些正方形可以填充可用空間。使用Android Constraintlayout創(chuàng)建一排均勻分布的正方形

我到底想要的布局,看起來像這樣:

的想法是,與不同的寬高比手機這個正方形成長一點點地使用了額外的空間。

我設(shè)法創(chuàng)建權(quán)重鏈與此布局

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/activity_main_inference"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/textView1"

android:layout_width="32dp"

android:layout_height="0dp"

android:text="All"

app:layout_constraintDimensionRatio="w,1:1"

app:layout_constraintHorizontal_weight="1"

app:layout_constraintLeft_toLeftOf="parent"

app:layout_constraintRight_toLeftOf="@+id/textView2"

app:layout_constraintTop_toTopOf="parent" />

android:id="@+id/textView2"

android:layout_width="32dp"

android:layout_height="0dp"

android:text="2"

app:layout_constraintDimensionRatio="w,1:1"

app:layout_constraintHorizontal_weight="1"

app:layout_constraintLeft_toRightOf="@+id/textView1"

app:layout_constraintRight_toLeftOf="@id/textView4"/>

android:id="@+id/textView4"

android:layout_width="32dp"

android:layout_height="0dp"

android:text="4"

app:layout_constraintDimensionRatio="w,1:1"

app:layout_constraintHorizontal_weight="1"

app:layout_constraintLeft_toRightOf="@+id/textView2"

app:layout_constraintRight_toRightOf="parent" />

這看起來是這樣的:

這是罰款只是Textviews的寬度是固定到32dp。 我希望,如果我將寬度也設(shè)置為零,匹配約束將首先確定所需的寬度以覆蓋所有空間,然后將高度設(shè)置為寬度以使視圖平方。

可悲的是我的布局是這樣的:

是這種想法,我想ContraintLayout實現(xiàn)可能布局的?

2017-08-14

Janusz

+0

你想這種類型的視圖https://i.stack.imgur.com/YQAoJ.png? –

+0

是的,這是我想要實現(xiàn)的。 –

總結(jié)

以上是生活随笔為你收集整理的android xml正方形,使用Android Constraintlayout创建一排均匀分布的正方形的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。