线性布局负边距,需要一个布局在另一个之上
Linear Layout negative margin , need one layout above another
我在给出负边距时遇到了这个问题
在给出负边距后,我希望红色部分低于白色部分,以便在红色框顶部获得类别的阴影,但如您所见,红色框位于顶部
白色部分是我的相对布局,红色部分是我的自定义列表视图
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dim_10"
android:layout_marginRight="@dimen/dim_10"
android:background="@drawable/stripe_sort"
android:layout_marginTop="@dimen/dim_5"
android:layout_marginBottom="-15dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dim_10"
android:text="Categories"
android:textColor="#ff000000"
android:textSize="13sp"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:checked="true"
android:src="@drawable/sort_downarrow"
android:layout_centerVertical="true"
android:padding="@dimen/dim_15"
android:id="@+id/dropDown_categories"/>
</RelativeLayout>
<com.eminosoft.ebookread.util.ExpandableHeightListView
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_marginLeft="@dimen/dim_12"
android:layout_marginRight="@dimen/dim_12"
android:background="#c03f2f"
android:id="@+id/ListView_Sort_categories"
android:visibility="visible"
android:paddingBottom="@dimen/dim_10"
android:divider="@null"
android:layout_gravity="center_horizontal"
/>
在此我向相对布局添加了负边距底部,我也尝试将负边距顶部添加到我的自定义列表视图但结果仍然相同,这两种布局的父布局都是线性布局
如何使列表视图低于相对布局?
<RelativeLayout
android:id="@+id/one"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.eminosoft.ebookread.util.ExpandableHeightListView
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_marginLeft="@dimen/dim_12"
android:layout_marginRight="@dimen/dim_12"
android:layout_marginTop="-15dp"
android:layout_below="@+id/partone"
android:background="#c03f2f"
android:id="@+id/ListView_Sort_categories"
android:visibility="visible"
android:paddingBottom="@dimen/dim_10"
android:divider="@null"
android:layout_gravity="center_horizontal"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dim_10"
android:layout_marginRight="@dimen/dim_10"
android:background="@drawable/stripe_sort"
android:layout_marginTop="@dimen/dim_5"
android:id="@+id/partone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dim_10"
android:text="Categories"
android:textColor="#ff000000"
android:textSize="13sp"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:checked="true"
android:src="@drawable/sort_downarrow"
android:layout_centerVertical="true"
android:padding="@dimen/dim_15"
android:id="@+id/dropDown_categories"/>
</RelativeLayout>
</RelativeLayout>
你可以试试这个代码,基本上我们把你的布局放在另一个相对布局里面
我在给出负边距时遇到了这个问题
在给出负边距后,我希望红色部分低于白色部分,以便在红色框顶部获得类别的阴影,但如您所见,红色框位于顶部
白色部分是我的相对布局,红色部分是我的自定义列表视图
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dim_10"
android:layout_marginRight="@dimen/dim_10"
android:background="@drawable/stripe_sort"
android:layout_marginTop="@dimen/dim_5"
android:layout_marginBottom="-15dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dim_10"
android:text="Categories"
android:textColor="#ff000000"
android:textSize="13sp"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:checked="true"
android:src="@drawable/sort_downarrow"
android:layout_centerVertical="true"
android:padding="@dimen/dim_15"
android:id="@+id/dropDown_categories"/>
</RelativeLayout>
<com.eminosoft.ebookread.util.ExpandableHeightListView
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_marginLeft="@dimen/dim_12"
android:layout_marginRight="@dimen/dim_12"
android:background="#c03f2f"
android:id="@+id/ListView_Sort_categories"
android:visibility="visible"
android:paddingBottom="@dimen/dim_10"
android:divider="@null"
android:layout_gravity="center_horizontal"
/>
在此我向相对布局添加了负边距底部,我也尝试将负边距顶部添加到我的自定义列表视图但结果仍然相同,这两种布局的父布局都是线性布局
如何使列表视图低于相对布局?
<RelativeLayout
android:id="@+id/one"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.eminosoft.ebookread.util.ExpandableHeightListView
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_marginLeft="@dimen/dim_12"
android:layout_marginRight="@dimen/dim_12"
android:layout_marginTop="-15dp"
android:layout_below="@+id/partone"
android:background="#c03f2f"
android:id="@+id/ListView_Sort_categories"
android:visibility="visible"
android:paddingBottom="@dimen/dim_10"
android:divider="@null"
android:layout_gravity="center_horizontal"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dim_10"
android:layout_marginRight="@dimen/dim_10"
android:background="@drawable/stripe_sort"
android:layout_marginTop="@dimen/dim_5"
android:id="@+id/partone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dim_10"
android:text="Categories"
android:textColor="#ff000000"
android:textSize="13sp"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:checked="true"
android:src="@drawable/sort_downarrow"
android:layout_centerVertical="true"
android:padding="@dimen/dim_15"
android:id="@+id/dropDown_categories"/>
</RelativeLayout>
</RelativeLayout>
你可以试试这个代码,基本上我们把你的布局放在另一个相对布局里面