Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.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奇怪的布局定位_Android_Android Layout - Fatal编程技术网

Android奇怪的布局定位

Android奇怪的布局定位,android,android-layout,Android,Android Layout,我有一个奇怪的布局定位问题。 这里有两个屏幕 正如你们在第一张截图上看到的,元素占据了2行。 xml布局的区别在于第一张图像上的android:layout_marginRight=“10dp”和第二张图像上的android:paddingRight=“10dp” <RelativeLayout android:layout_width="match_parent" android:layout_height="48dp"> <RelativeLayout

我有一个奇怪的布局定位问题。 这里有两个屏幕

正如你们在第一张截图上看到的,元素占据了2行。 xml布局的区别在于第一张图像上的android:layout_marginRight=“10dp”和第二张图像上的android:paddingRight=“10dp”

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="48dp">

<RelativeLayout
    android:id="@+id/rl_event_date_and_time"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="10dp"
    android:background="@drawable/date_time_left">

    <ImageView
        android:id="@+id/iv_date"
        android:layout_width="9dp"
        android:layout_height="10dp"
        android:layout_centerVertical="true"
        android:layout_marginLeft="12dp"
        android:background="@drawable/ic_event_date" />

    <TextView
        android:id="@+id/tv_event_date"
        fontPath="fonts/Roboto-Medium.ttf"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="6dp"
        android:layout_toRightOf="@id/iv_date"
        android:textColor="@color/white"
        android:textSize="15sp"/>

    <ImageView
        android:id="@+id/iv_time"
        android:layout_width="13dp"
        android:layout_height="13dp"
        android:layout_centerVertical="true"
        android:layout_marginLeft="9dp"
        android:layout_toRightOf="@id/tv_event_date"
        android:background="@drawable/ic_event_time" />

    <TextView
        android:id="@+id/tv_event_time"
        fontPath="fonts/Roboto-Medium.ttf"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="4dp"
        android:paddingRight="10dp" // Here is difference
        android:layout_toRightOf="@id/iv_time"
        android:textColor="@color/white"
        android:textSize="15sp"/>

</RelativeLayout>

    <Button
        android:id="@+id/btn_event_remind"
        style="@style/MaterialButtonBorderLess"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="2dp"
        android:text="@string/event_remind"
        android:visibility="gone"/>

</RelativeLayout>
接下来的效果是:


您应该在标签上使用android:singleLine=“true”,以确保无论其大小都不会包装。

在布局上使用此功能


android:singleLine=“true”

如果我使用的是
singleLine
文本正在剪切,a不希望看到这种行为。我明天可以提供屏幕。我做了一个
单线
效果的屏幕截图。如果我使用
单线
文本正在剪切,a不想看到这种行为。我明天可以提供屏幕。
android:layout_marginRight="10dp"
android:singleLine="true"