9

私はチュートリアルに従っていましたが、垂直にも水平にも指定されていない線形レイアウトがあることに気付きました。別のチュートリアルで、基本的に必須であると言われました...どちらも持っていないということはどういう意味ですか? 悪いですか?これは、DID を実行する別の線形レイアウトによって囲まれていました。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/group"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Add New" 
            android:onClick="onClick"/>

        <Button
            android:id="@+id/delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Delete First" 
            android:onClick="onClick"/>

    </LinearLayout>

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

 </LinearLayout>
4

3 に答える 3

18

orientationデフォルトがであることを意味するだけhorizontalです。したがって、属性が存在しない場合、線形レイアウトは水平線形レイアウトです。

于 2012-06-20T17:34:50.663 に答える
6

LinearLayoutorientationのが指定されていない場合、デフォルトの が使用ますhorizontal

公式ドキュメントによると:

Android:向き

レイアウトは列にするか行にするか? 行には「水平」、列には「垂直」を使用します。デフォルトは水平です。

LinearLayoutのクラスの概要にも記載されています。

クラス概要

子を 1 つの列または 1 つの行に配置するレイアウト... デフォルトの向きは水平です。

そしてまたsetOrientation()

public void setOrientation(int 方向)

...

パラメーター

orientation           HORIZONTAL または VERTICAL を渡します。デフォルト値は HORIZONTAL です。

于 2013-01-13T08:48:07.083 に答える
3

linearlayout のデフォルトの方向は「水平」です

于 2012-06-20T18:22:52.813 に答える