Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在RelativeLayout中正确调整两个文本视图之间的间距_Android_Xml_Android Layout_Android Relativelayout_Textview - Fatal编程技术网

Android 在RelativeLayout中正确调整两个文本视图之间的间距

Android 在RelativeLayout中正确调整两个文本视图之间的间距,android,xml,android-layout,android-relativelayout,textview,Android,Xml,Android Layout,Android Relativelayout,Textview,我一整天都在编辑我的相亲照片,但我无法制作出令人满意的屏幕 现在看起来是这样的: 它没有居中,在小时时间和分钟时间之间有一个非常尴尬的空间 我正试图找出如何修复它,使它的中心类似于这个应用程序,除了我包括小h和m 我做了很多研究,在相对布局中使用了几乎所有的定位视图,但仍然无法生成它 这是我的xml文件。不知道该怎么办我觉得我已经用尽了所有的选择 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and

我一整天都在编辑我的相亲照片,但我无法制作出令人满意的屏幕

现在看起来是这样的:

它没有居中,在小时时间和分钟时间之间有一个非常尴尬的空间

我正试图找出如何修复它,使它的中心类似于这个应用程序,除了我包括小h和m

我做了很多研究,在相对布局中使用了几乎所有的定位视图,但仍然无法生成它

这是我的xml文件。不知道该怎么办我觉得我已经用尽了所有的选择

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:seekarc="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/seekArcContainer"
        android:layout_width="350dp"
        android:layout_height="wrap_content"
        >

    </FrameLayout>

    <include
        layout="@layout/controls"
        android:id="@+id/controls" />

    <com.triggertrap.seekarc.SeekArc
        android:id="@+id/seekArc"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center_horizontal|bottom"
        seekarc:thumb="@drawable/custom_seek_arc_control_selector"
        android:padding="30dp"
        seekarc:rotation="0"
        seekarc:startAngle="0"
        seekarc:sweepAngle="360"
        seekarc:touchInside="true"
        seekarc:arcColor="#30ff5b56"
        seekarc:progressColor="#ffff3a35"
        android:layout_below="@+id/seekArcContainer"
        android:layout_centerHorizontal="true" />

    <TextView
        android:id="@+id/hour_progress_number"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textColor="@color/red_highlight"
        android:text="00"



        android:textSize="90sp"
        android:layout_toStartOf="@+id/little_hour_text2"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />


    <TextView
        android:id="@+id/minute_progress_number"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textColor="@color/red_highlight"


        android:text="00"
        android:textSize="90sp"
        android:layout_toStartOf="@+id/little_minute_text2"
        android:layout_alignTop="@+id/hour_progress_number"
        android:layout_toLeftOf="@+id/little_minute_text2" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="H"
        android:textSize="24sp"



        android:id="@+id/little_hour_text2"

        android:textColor="@color/red_highlight"

        android:layout_toStartOf="@+id/minute_progress_number"
        android:layout_marginRight="45dp"
        android:layout_alignBottom="@+id/hour_progress_number"
        android:layout_toLeftOf="@+id/minute_progress_number" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="M"
        android:textSize="24sp"
        android:id="@+id/little_minute_text2"
        android:textColor="@color/red_highlight"

        android:layout_marginRight="36dp"
        android:layout_alignRight="@+id/seekArc"
        android:layout_alignEnd="@+id/seekArc"
        android:layout_alignBottom="@+id/minute_progress_number" />


</RelativeLayout>

试试这段代码,愿这段xml对您有所帮助..您可以从中吸取教训。如果有任何问题,请询问

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="300dp"
        android:layout_height="300dp" >

        <com.triggertrap.seekarc.SeekArc
            android:id="@+id/seekArc"
            android:layout_width="300dp"
            android:layout_height="300dp"
            android:layout_centerInParent="true" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:orientation="horizontal" >

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="00"
                    android:textSize="60sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="H"
                    android:textSize="30sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="00"
                    android:textSize="60sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="M"
                    android:textSize="30sp" />
            </LinearLayout>
        </LinearLayout>
    </RelativeLayout>

</LinearLayout>

你要找的是第二个答案(不是公认的答案)。在两个视图中间使用撑杆。

这是答案中给出的示例:

<RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <View android:id="@+id/strut"
        android:layout_width="0dp"
        android:layout_height="0dp" 
        android:layout_centerHorizontal="true"/>
    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignRight="@id/strut"
        android:layout_alignParentLeft="true"
        android:text="Left"/> 
    <Button 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@id/strut"
        android:layout_alignParentRight="true"
        android:text="Right"/>
</RelativeLayout>


小时和分钟文本字段能否仅为一个文本字段?嗯。这样,你只需要担心对1个文本字段进行定心,而不是:(在中间放置一个虚拟视图,然后放置那个虚拟视图的小时和分钟的扭矩)。