簡體   English   中英

Android橫向和縱向模式變化

[英]Android Landscape and Portrait Modes variation

大家好,我正在android 2.2中制作一個應用程序,它的布局在線性布局中有一些文本字段,在頁面底部還有一些圖像按鈕 它在“縱向”視圖上的視圖是完美的,但是現在當我通過按CTRL + F11轉到“橫向”視圖時,其底部的“圖像”按鈕不顯示。

我想要的是通過代碼引導我,如果我的手機進入橫向模式,它將檢查其模式並更改按鈕的位置,以便圖像按鈕應可見。

請拜托請朋友幫我

等待您的積極回應和指導。

在項目的res文件夾中,創建一個名為“ layout-land”的子文件夾。 將您的protrait布局xml文件復制到該文件夾​​,然后根據您的景觀需求對其進行編輯。 現在,每次更改設備的方向時,布局都會自動進行調整。 就那么簡單

除了@Steff的建議外,讓我添加另一件事。 在創建布局區域文件夾並創建XML之后,您可以考慮將布局元素封裝在ScrollView中。 我遇到了類似的問題,該解決方案非常適合我。 這是一個代碼片段:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_weight="1"   >
    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" >
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="3dp"   >
                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:text="NAME"
                    android:padding="3dp"
                    android:textColor="#666666"
                    android:textSize="16sp" >
                </TextView>
                <TextView
                    android:text="Name"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/summaryContactName"
                    android:padding="3dp"
                    android:textColor="#111111"
                    android:textSize="17sp" >
                </TextView>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

您在ScrollView下放置的所有元素將確保屏幕內容永不中斷。

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM