第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

GridLayout 中的按鈕對齊

GridLayout 中的按鈕對齊

白板的微信 2021-08-19 19:05:57
我的布局代碼及其圖形表示如下所示:這是它的外觀:當(dāng)我嘗試在網(wǎng)格布局中放入按鈕時(shí),它不顯示。我嘗試將行數(shù)和列數(shù)設(shè)置為 2,但似乎不起作用。我想讓布局看起來像這樣:我已經(jīng)放了一個按鈕,但它不可見:
查看完整描述

2 回答

?
森欄

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個贊

實(shí)際的 xml 文件是什么樣的?這會更有幫助,但在看不到您的 xml 文件時(shí),請確保所有按鈕都在網(wǎng)格布局標(biāo)簽內(nèi)。設(shè)置網(wǎng)格布局的寬度和高度以匹配父級,如果您想保留所有內(nèi)容,甚至將列數(shù)和行數(shù)設(shè)置為 2 然后在您的按鈕上,您必須在每個按鈕上將 layout_columnweight 和 layout_rowweight 設(shè)置為 1,這樣它們只占用 1網(wǎng)格上的部分。嘗試從那個開始,就像我說的,如果你發(fā)布你的 xml 文件,我將能夠告訴你到底出了什么問題


它應(yīng)該看起來像這樣


<GridLayout xmlns:android="//schemas.android.com/apk/res/android"

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

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:columnCount="2"

    android:rowCount="2">

    <Button

        android:layout_columnWeight="1"

        android:layout_rowWeight="1"

        android:background="#color you want"

        android:textSize="size you want"

        android:text="text you want" />

    <Button

        android:layout_columnWeight="1"

        android:layout_rowWeight="1"

        android:background="#color you want"

        android:textSize="size you want"

        android:text="text you want" />

    <Button

        android:layout_columnWeight="1"

        android:layout_rowWeight="1"

        android:background="#color you want"

        android:textSize="size you want"

        android:text="text you want" />

    <Button

        android:layout_columnWeight="1"

        android:layout_rowWeight="1"

        android:background="#color you want"

        android:textSize="size you want"

        android:text="text you want" />

</GridLayout>


查看完整回答
反對 回復(fù) 2021-08-19
?
繁華開滿天機(jī)

TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超4個贊

你可以用android:gravity=""屬性來做,看下面的代碼它認(rèn)為它就像你想要的


<?xml version="1.0" encoding="utf-8"?>

<GridLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:columnCount="2">


<Button

    android:layout_width="0dp"

    android:layout_height="100dp"

    android:layout_columnWeight="1"

    android:gravity="center"

    android:layout_gravity="fill_horizontal"

    android:background="@color/colorAccent"

    android:text="Title1" />


    <Button

        android:layout_width="0dp"

        android:layout_height="100dp"

        android:layout_columnWeight="1"

        android:gravity="center"

        android:layout_gravity="fill_horizontal"

        android:background="@color/colorPrimaryDark"

        android:text="Title2" />


        <Button

            android:layout_width="0dp"

            android:layout_height="100dp"

            android:layout_columnWeight="1"

            android:gravity="center"

            android:layout_gravity="fill_horizontal"

            android:background="@color/colorPrimary"

            android:text="Title3" />


            <Button

                android:layout_width="0dp"

                android:layout_height="100dp"

                android:layout_columnWeight="1"

                android:gravity="center"

                android:layout_gravity="fill_horizontal"

                android:background="@color/colorAccent"

                android:text="Title4" />


 </GridLayout>



查看完整回答
反對 回復(fù) 2021-08-19
  • 2 回答
  • 0 關(guān)注
  • 197 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號