簡體   English   中英

Android視圖:獲取視圖以捕捉到屏幕的左側

[英]Android Views: Getting a view to snap to the left hand side of the screen

我有2個視圖,一個是滾動視圖,另一個是LinearLayout。 我希望LinearLayout為固定大小,我大約為80dp。 我希望此布局始終在屏幕的右側。 我想讓Scroll View占用其余的空間。 這是我的代碼的樣子。

     <LinearLayout
    android:id="@+id/widget4327"
    android:layout_below="@+id/line"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#F4F5DC">


<ScrollView 
    android:id="@+id/ScrollView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="left"
    android:layout_below="@+id/line">

</ScrollView>

<LinearLayout
    android:id="@+id/linearL2"
    android:background="#EEEFE0"
    android:layout_gravity="right"
    android:layout_height="fill_parent"
    android:layout_width="80dp"
    android:orientation="vertical"
    android:gravity="left"
    android:layout_toRightOf="@id/ScrollView01">

</LinearLayout>

</LinearLayout>

我以為重力會解決這個問題,但我似乎無法使它正常工作。 有任何想法嗎?

如果使用RelativeLayout則可以將alignToParentLeft設置為true

暫無
暫無

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

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