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

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

將相對布局轉換為線性布局

將相對布局轉換為線性布局

有只小跳蛙 2023-05-17 15:04:20
我正在開發(fā)一個 Android 應用程序,對于圖形部分,我正在使用有用的 Android Studio 編輯器。這意味著我正在使用邊距命令移動對象,使它們完美適合 Google Pixel C 屏幕?,F(xiàn)在我在平板電腦上試用了這個應用程序,當然,它不起作用。我讀到我應該使用線性布局,但我認為我想要轉換的代碼不遵守它的規(guī)則,因為我在每一行和不同的位置都有元素。我如何用線性布局來表示它?這是代碼,您可以看到它為每個元素指定了邊距。<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:background="@drawable/background_main"    android:scaleType = "centerCrop"    tools:context=".MainActivity">    <TextView        android:id="@+id/textView2"        android:layout_width="1063dp"        android:layout_height="476dp"        android:layout_marginLeft="275dp"        android:layout_marginTop="200dp"        android:fontFamily="@font/kotta_one"        android:text="Test del pensiero\n      divergente"        android:textColor="#000000"        android:textSize="100dp"        android:textStyle="bold"        tools:layout_editor_absoluteX="78dp"        tools:layout_editor_absoluteY="123dp" />    <Button        android:id="@+id/button_1"        android:layout_width="200dp"        android:layout_height="50dp"        android:layout_marginLeft="400dp"        android:layout_marginTop="480dp"        android:background="@drawable/button_bg"        android:text="@string/invioA"        android:textAllCaps="false"        android:textColor="#FFFFFF"        android:textSize="18dp"        app:layout_constraintVertical_bias="0.771" /></RelativeLayout>
查看完整描述

2 回答

?
哆啦的時光機

TA貢獻1779條經驗 獲得超6個贊

好的,試試這個:


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

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

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@drawable/bg"

android:orientation="vertical">


<Button

    android:id="@+id/button_3"

    android:layout_width="90dp"

    android:layout_height="70dp"

    android:background="@android:color/transparent"

    android:text="Area\nDocenti"

    android:textAllCaps="false"

    android:textColor="#030000"

    android:textSize="24dp"

    app:layout_constraintVertical_bias="0.771" />



<RelativeLayout

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:layout_gravity="center"

    android:layout_marginTop="200dp">


    <TextView

        android:id="@+id/textView2"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginBottom="30dp"

        android:fontFamily="@font/kotta_one"

        android:text="Test del pensiero\n      divergente"

        android:textColor="#000000"

        android:textSize="100dp"

        android:textStyle="bold" />


    <LinearLayout

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_below="@+id/textView2"

        android:layout_centerInParent="true"

        android:orientation="horizontal">


        <Button

            android:id="@+id/button_1"

            android:layout_width="200dp"

            android:layout_height="50dp"

            android:layout_marginRight="40dp"

            android:background="@android:color/black"

            android:text="Protocollo A"

            android:textAllCaps="false"

            android:textColor="#FFFFFF"

            android:textSize="18dp"

            app:layout_constraintVertical_bias="0.771" />


        <Button

            android:id="@+id/button_2"

            android:layout_width="200dp"

            android:layout_height="50dp"

            android:layout_marginLeft="40dp"

            android:background="@android:color/black"

            android:text="Protocollo B"

            android:textAllCaps="false"

            android:textColor="#FFFFFF"

            android:textSize="18dp"

            app:layout_constraintVertical_bias="0.771" />


    </LinearLayout>

</RelativeLayout>



查看完整回答
反對 回復 2023-05-17
?
心有法竹

TA貢獻1866條經驗 獲得超5個贊

我認為你最好的選擇是使用ConstraintLayout

但是 LinearLayout 的一些快速和 hacky:

<LinearLayout

? android:layout_width="match_parent"

? android:layout_height="match_parent"

? android:orientation="vertical" >


? ? <Button

? ? ? ? android:id="@+id/button_3"

? ? ? ? android:layout_width="wrap_content"

? ? ? ? android:layout_height="wrap_content"

? ? ? ? android:layout_gravity="start"

? ? ? ? android:layout_margin_start="20dp"

? ? ? ? android:background="@android:color/transparent"

? ? ? ? android:fontFamily="@font/kotta_one"

? ? ? ? android:text="Area\nDocenti"

? ? ? ? android:textAllCaps="false"

? ? ? ? android:textColor="#030000"

? ? ? ? android:textSize="24dp"/>


? ?<LinearLayout

? ? ?android:layout_width="wrap_content"

? ? ?android:layout_height="wrap_content"

? ? ?android:orientation="vertical"?

? ? ?android:layout_gravity="centre"

? ? ?android:gravity="centre">

? ? ? ?<TextView

? ? ? ? android:id="@+id/textView2"

? ? ? ? android:layout_width="wrap_content"

? ? ? ? android:layout_height="wrap_content"

? ? ? ? android:fontFamily="@font/kotta_one"

? ? ? ? android:text="Test del pensiero"

? ? ? ? android:textColor="#000000"

? ? ? ? android:textSize="100dp"

? ? ? ? android:textStyle="bold"/>

? ? ? <TextView

? ? ? ? android:id="@+id/textView2"

? ? ? ? android:layout_width="wrap_content"

? ? ? ? android:layout_height="wrap_content"

? ? ? ? android:fontFamily="@font/kotta_one"

? ? ? ? android:text="divergente"

? ? ? ? android:textColor="#000000"

? ? ? ? android:textSize="100dp"

? ? ? ? android:textStyle="bold"/>


? ? ? <LinearLayout

? ? ? ? ?android:layout_width="wrap_content"

? ? ? ? ?android:layout_height="wrap_content"

? ? ? ? ?android:orientation="horizontal">


? ? ? ? ? ? ? ? ?<Button

? ? ? ? ? ? ? ? ? ?android:id="@+id/button_1"

? ? ? ? ? ? ? ? ? ?android:layout_width="wrap_content"

? ? ? ? ? ? ? ? ? ?android:layout_height="wrap_content"

? ? ? ? ? ? ? ? ? ?android:background="@drawable/button_bg"

? ? ? ? ? ? ? ? ? ?android:text="@string/invioA"

? ? ? ? ? ? ? ? ? ?android:textAllCaps="false"

? ? ? ? ? ? ? ? ? ?android:textColor="#FFFFFF"

? ? ? ? ? ? ? ? ? ?android:textSize="18dp"/>


? ? ? ? ? ? ? ? <Button

? ? ? ? ? ? ? ? ? ?android:id="@+id/button_2"

? ? ? ? ? ? ? ? ? ?android:layout_width="wrap_content"

? ? ? ? ? ? ? ? ? ?android:layout_height="wrap_content"

? ? ? ? ? ? ? ? ? ?android:background="@drawable/button_bg"

? ? ? ? ? ? ? ? ? ?android:text="@string/invioB"

? ? ? ? ? ? ? ? ? ?android:textAllCaps="false"

? ? ? ? ? ? ? ? ? ?android:textColor="#FFFFFF"

? ? ? ? ? ? ? ? ? ?android:textSize="18dp"/>

? ? ? </LinearLayout>

? ?</LinearLayout>

</LinearLayout>

這可能不是完美的,因為我只是徒手寫的,但我認為它讓你很好地了解你可以做什么。


查看完整回答
反對 回復 2023-05-17
  • 2 回答
  • 0 關注
  • 287 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號