2015-06-11 57 views
1

Here是我所拥有的:如何覆盖RelativeLayout中的视图?

是否有可能以某种方式降低按钮重叠层,但没有更改布局。我正在使用Relative。 问题是,当按钮进入数字的位置小部分的按钮不可见。 .XML的

这里的片段:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:materialdesign="http://schemas.android.com/apk/res-auto" 
xmlns:fab="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="65dp" 
android:orientation="vertical" 
android:padding="8dp" 
android:background="@drawable/shadow_listitem"> 

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" android:text="Task is Finish!" 
      android:id="@+id/txtFinish" 
      android:visibility="gone" 

      android:layout_alignBottom="@+id/tvDays" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true"/> 
<TextView android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 

      android:textAppearance="?android:attr/textAppearanceLarge" android:text="Name" android:id="@+id/tvName" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true"/> 
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:layout_marginLeft="-27dp" 
      android:text="0000" android:id="@+id/tvDays" 
      android:layout_alignTop="@+id/textView4" 
      android:layout_toLeftOf="@+id/textView4" 
      android:layout_toStartOf="@+id/textView4"/> 

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/tvHours" 
      android:layout_toLeftOf="@+id/textView2" 
      android:layout_toStartOf="@+id/textView2" 
      android:layout_below="@+id/tvName"/> 

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/tvMinutes" 

      android:layout_alignTop="@+id/textView8" 
      android:layout_toLeftOf="@+id/textView8" 
      android:layout_toStartOf="@+id/textView8"/> 
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" android:text=":" android:id="@+id/textView8" 
      android:layout_alignTop="@+id/tvSeconds" 
      android:layout_toLeftOf="@+id/tvSeconds" 
      android:layout_toStartOf="@+id/tvSeconds"/> 
<TextView android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/tvSeconds" 

      android:layout_below="@+id/tvName" 
      android:layout_alignRight="@+id/tvName" 
      android:layout_alignEnd="@+id/tvName"/> 
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" android:text="Limit: " 
      android:visibility="gone" android:id="@+id/txtLimit" 
      android:layout_alignBottom="@+id/tvDays" 
      android:layout_toLeftOf="@+id/tvDays" 
      android:layout_toStartOf="@+id/tvDays" 
      android:layout_marginRight="133dp" 

      android:layout_marginEnd="93dp"/> 
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/limDay" 
      android:visibility="gone" 
      android:layout_marginLeft="50dp" 
    android:layout_alignBottom="@+id/txtLimit" 
      android:layout_marginStart="50dp" 
      android:layout_alignTop="@+id/tvDays" 

      android:layout_alignLeft="@+id/txtLimit" 
      android:layout_alignStart="@+id/txtLimit"/> 
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/limHours" 
      android:visibility="gone" 
    android:layout_alignBottom="@+id/txtLimit" 

      android:layout_alignTop="@+id/limDay" 
      android:layout_toRightOf="@+id/limDay" 
      android:layout_toEndOf="@+id/limDay"/> 
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/limMin" 
      android:visibility="gone" 
      android:layout_alignTop="@+id/limHours" 
    android:layout_toRightOf="@+id/limHours" 

    android:layout_alignBottom="@+id/txtLimit" 
      /> 
<com.software.shell.fab.ActionButton 
    android:id="@+id/btStart" 
    style="@style/fab_action_button_style" 
    fab:type="mini" 
    fab:image="@drawable/fab_plus_icon" 
    fab:rippleEffect_enabled="true" 
    fab:button_color="@color/primaryColor" 
    android:focusable="false" 
    fab:shadowResponsiveEffect_enabled="true" 
    fab:button_colorRipple="@color/primaryColorDark" 
    fab:button_colorPressed="@color/fab_material_blue_500" 
    android:layout_alignParentTop="true" 
    android:layout_marginTop="-14dp" 
    fab:shadow_yOffset="0.0dp" 
    android:layout_alignParentStart="true" /> 

回答

4

要覆盖你的父母布局应该是一个FrameLayout里。例如:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/map_place_box" 
    android:layout_width="200dp" 
    android:layout_height="wrap_content" 
    android:background="@color/primary" 
    android:padding="10dp"> 

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

    <TextView 
     android:id="@+id/place" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Casa da mae joana" 
     android:textColor="@android:color/white" 
     android:textSize="25dp" 
     /> 
</FrameLayout> 

文本视图覆盖图像。

我希望它有帮助。

0

您可以将FrameLayout保留在层次结构顶部。然后在此FrameLayout中保留RelativeLayout和ActionButton。
您的视图层级应该是这样的:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/map_place_box" 
    android:layout_width="200dp" 
    android:layout_height="wrap_content" 
    android:background="@color/primary" 
    android:padding="10dp"> 

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
    // Keep all of your textviews inside this Relative Layout. 
    </RelativeLayout> 
    <com.software.shell.fab.ActionButton 
     android:id="@+id/btStart" 
     style="@style/fab_action_button_style" 
     fab:type="mini" 
     fab:image="@drawable/fab_plus_icon" 
     fab:rippleEffect_enabled="true" 
     fab:button_color="@color/primaryColor" 
     android:focusable="false" 
     fab:shadowResponsiveEffect_enabled="true" 
     fab:button_colorRipple="@color/primaryColorDark" 
     fab:button_colorPressed="@color/fab_material_blue_500" 
     android:layout_alignParentTop="true" 
     android:layout_marginTop="-14dp" 
     fab:shadow_yOffset="0.0dp" 
     android:layout_alignParentStart="true" /> 
</FrameLayout>