两个相对布局之间存在差距

时间:2016-05-26 13:11:27

标签: android xml relativelayout

两个相对布局之间存在差距。我想消除这个差距。

this is the image of the above xml

我的xml图像在下面给出

<RelativeLayout
    android:id="@+id/live_view_surface_view_rl"
    android:layout_width="fill_parent"
    android:layout_height="@dimen/video_height">

    <RelativeLayout
        android:id="@+id/surfaceview_rl"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/palette_rl">

        <SurfaceView
            android:id="@+id/surfaceview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_centerInParent="true">
        </SurfaceView>        
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/palette_rl"
        android:layout_width="fill_parent"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true"
        android:background="@color/transperent_black_color">

        <RelativeLayout
            android:id="@+id/snapshot_button_rl"
            android:layout_width="50dp"
            android:layout_height="fill_parent"
            android:layout_marginLeft="@dimen/margin_left_right">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:src="@drawable/snapshotselection" />
        </RelativeLayout>

        <LinearLayout
            android:id="@+id/mic_btn_rl_parent"
            android:layout_width="100dp"
            android:layout_height="fill_parent"
            android:layout_toRightOf="@+id/snapshot_button_rl"
            android:orientation="horizontal">

            <RelativeLayout
                android:id="@+id/mic_button_rl"
                android:layout_width="50dp"
                android:layout_height="fill_parent">

                <ImageView
                    android:id="@+id/mic_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:src="@drawable/talkbackbtn_selector" />

                <ProgressBar
                    android:id="@+id/start_talkback_progress"
                    android:layout_width="@dimen/field_width_small"
                    android:layout_height="@dimen/field_width_small"
                    android:layout_centerInParent="true"
                    android:visibility="gone" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/live_view_audio_icon_rl"
                android:layout_width="@dimen/field_width_medium"
                android:layout_height="fill_parent">

                <ImageView
                    android:id="@+id/live_view_audio_icon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:src="@drawable/icon_volume" />
            </RelativeLayout>
        </LinearLayout>
    </RelativeLayout>
</RelativeLayout>

这个差距保持不变,即使我增加了下面相对布局的高度。 两种布局都具有相同的父级,但它们仍然没有相同的调整。

2 个答案:

答案 0 :(得分:0)

Hello只需复制粘贴并在相对布局中编写xml

<LinearLayout      xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="8">

</RelativeLayout>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="2">

</RelativeLayout>

答案 1 :(得分:0)

将weightsum = 1设置为父布局(palette_rl)。将set weight = 0.25设置为所有子相对布局并保持其layout_width = 0dip.it正常工作。以相同的顺序调整所有空间。

请使用以下xml.I更改高度和尺寸以及可绘制。所以,请调整它。它工作正常。删除黑线。

<?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
     android:layout_height="match_parent"
    tools:context=".MainActivity" >
 <RelativeLayout
android:id="@+id/live_view_surface_view_rl"
android:layout_width="fill_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:id="@+id/surfaceview_rl"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
   >

    <SurfaceView
        android:id="@+id/surfaceview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerInParent="true">
    </SurfaceView>        
</RelativeLayout>

<RelativeLayout
    android:id="@+id/palette_rl"
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    android:layout_alignParentBottom="true"
    android:background="#ab00aa">

    <RelativeLayout
        android:id="@+id/snapshot_button_rl"
        android:layout_width="50dp"
        android:layout_height="fill_parent"
        android:layout_marginLeft="10dp">

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

    <LinearLayout
        android:id="@+id/mic_btn_rl_parent"
        android:layout_width="100dp"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@+id/snapshot_button_rl"
        android:orientation="horizontal">

        <RelativeLayout
            android:id="@+id/mic_button_rl"
            android:layout_width="50dp"
            android:layout_height="fill_parent">

            <ImageView
                android:id="@+id/mic_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:src="@drawable/ic_launcher" />

            <ProgressBar
                android:id="@+id/start_talkback_progress"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_centerInParent="true"
                android:visibility="gone" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/live_view_audio_icon_rl"
            android:layout_width="50dp"
            android:layout_height="fill_parent">

            <ImageView
                android:id="@+id/live_view_audio_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:src="@drawable/ic_launcher" />
        </RelativeLayout>
    </LinearLayout>
</RelativeLayout>

相关问题