如何获取Framelayout wrap_content直到horizo​​ntalScrollview

时间:2012-10-26 06:55:43

标签: android

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/quickaction_shadow_horiz"
    android:paddingRight="@dimen/quickaction_shadow_horiz">

    <FrameLayout
        android:id="@+id/header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip">
        <LinearLayout
            android:id="@+id/quickaction_header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/quickaction_top_frame"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/quickaction_icon"
                android:layout_width="54dip"
                android:layout_height="57dip"
                android:layout_marginLeft="15dip"
                android:layout_marginTop="5dip"
                android:layout_marginBottom="5dip"
                android:scaleType="center" 
                android:visibility="gone" />

            <LinearLayout
                android:id="@+id/quickaction_header_content"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginLeft="15dip"
                android:layout_marginRight="15dip"
                android:orientation="vertical"
                android:visibility="gone">
                <TextView
                    android:id="@+id/quickaction_primary_text"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:singleLine="true"
                    android:ellipsize="marquee"
                    android:textColor="@android:color/primary_text_light"
                    android:textStyle="bold"
                    android:textSize="18dip"
                    android:visibility="gone" />

                <TextView
                    android:id="@+id/quickaction_secondary_text"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textColor="@android:color/secondary_text_light"
                    android:textSize="15dip"
                    android:layout_marginTop="-3dip"
                    android:visibility="gone" />
            </LinearLayout>
        </LinearLayout>
    </FrameLayout>

    <HorizontalScrollView
        android:id="@+id/scroll"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/header"
        android:fadingEdgeLength="0dip"
        android:background="@drawable/quickaction_slider_background"
        android:scrollbars="none">

        <LinearLayout
            android:id="@+id/quickaction"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="4dip"
            android:paddingBottom="4dip"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/quickaction_slider_grip_left" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/quickaction_slider_grip_right" />

        </LinearLayout>

    </HorizontalScrollView>

    <FrameLayout
        android:id="@+id/footer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/scroll"
        android:background="@drawable/quickaction_bottom_frame" />

    <!--  <LinearLayout
        android:id="@+id/footer_disambig"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/scroll"
        android:background="@drawable/quickaction_disambig_bottom_bg"
        android:orientation="vertical"
        android:visibility="gone">

        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:background="@color/quickaction_disambig"
            android:divider="@drawable/quickaction_disambig_divider"
            android:cacheColorHint="@null" />

        <CheckBox
            android:id="@+id/checkbox"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="19dip"
            android:layout_marginRight="19dip"
            android:minHeight="60dip"
            android:textColor="#f000"
            android:textStyle="bold"
            android:text="Remember Choice"
            android:textAppearance="?android:attr/textAppearanceSmallInverse"
            android:button="@drawable/quickaction_disambig_checkbox" />

    </LinearLayout> -->

    <ImageView
        android:id="@+id/arrow_up"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/quickaction_arrow_up" />

    <ImageView
        android:id="@+id/arrow_down"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="-1dip"
        android:layout_below="@id/footer"
        android:src="@drawable/quickaction_arrow_down" />

    <!-- <ImageView
        android:id="@+id/arrow_down_stub"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="-1dip"
        android:layout_below="@id/footer_disambig"
        android:visibility="invisible"
        android:src="@drawable/quickaction_arrow_down" />-->

</RelativeLayout>

你好我希望我的Framelayout与Horizo​​ntalscrollview具有相同的宽度我没有采取Horizo​​ntalscrollview的宽度只是在开始位置停留在那里如果给出wrap_content但是需要fill_parent我想保留wrap_content我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

<HorizontalScrollView>内添加以下两行并试一试:

android:layout_alignLeft="@id/header"
android:layout_alignRight="@id/header"

希望这会有所帮助。