关于ui的问题

The issue about ui

看我截图的图片,我用图片来说明我的问题。

以下是我的布局代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >

<TextView
    android:id="@+id/one"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:drawableRight="@drawable/hexun_dh6"
    android:gravity="center_vertical"
    android:text="你好" />

<TextView
    android:id="@+id/two"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:drawableRight="@drawable/hexun_dh6"
    android:gravity="center_vertical"
    android:text="你好" />

<TextView
    android:id="@+id/three"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:drawableRight="@drawable/hexun_dh6"
    android:gravity="center_vertical"
    android:text="你好" />

<TextView
    android:id="@+id/four"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:drawableRight="@drawable/hexun_dh6"
    android:gravity="center_vertical"
    android:text="你好" />

布局结果就像上图一样,我的疑问是为什么文本远离可绘制的,我想要结果:

我尝试将 drawablepadding 设置为小于零,但它不起作用,我该怎么做,我只想使用这种方式,不想使用 TextViewImageView ,感谢先进。

这是另一个 hacky 解决方案。试试这个 :)

诀窍是你把 invisible View between your TextViews 和你的 textViews 将有简单的 wrap_content 作为宽度。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <View
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="1" />

    <TextView
        android:id="@+id/one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableRight="@drawable/big_star_orange"
        android:gravity="center"
        android:text="你好" />

    <View
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="1" />

    <TextView
        android:id="@+id/two"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableRight="@drawable/big_star_orange"
        android:gravity="center"
        android:text="你好" />

    <View
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="1" />

    <TextView
        android:id="@+id/three"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableRight="@drawable/big_star_orange"
        android:gravity="center"
        android:text="你好" />

    <View
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="1" />

    <TextView
        android:id="@+id/four"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableRight="@drawable/big_star_orange"
        android:gravity="center"
        android:text="你好" />

    <View
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="1" />
</LinearLayout>

之后就不需要重心了,只需要重心就可以了。希望对您有所帮助!