开发者

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

开发者 https://www.devze.com 2023-02-13 12:12 出处:网络
I have 2 views one is a scroll view and the other is a LinearLayout.I want the LinearLayout to be a fixed size, i have it about 80dp.I want this layout to be on the right hand side of my screen the wh

I have 2 views one is a scroll view and the other is a LinearLayout. I want the LinearLayout to be a fixed size, i have it about 80dp. I want this layout to be on the right hand side of my screen the whole time. The rest of the space i want my Scroll View to take up. Here is what my code looks like.

     <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>

I thought the gravity开发者_如何学运维 would take care of this but i cant seem to get it working. Any ideas?


If you use a RelativeLayout then you can set the alignToParentLeft to true

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号