相关疑难解决方法(0)

Android中的alignBaseline和alignBottom有什么区别?

我试过两个对齐几个TextView对象,他们给了我相同的结果."基线"和"底部"之间究竟有什么区别?

android android-relativelayout

27
推荐指数
1
解决办法
2万
查看次数

Android - 在同一基线上对齐不同的字体大小

我有 2 个相邻的TextViews,每个都有一个不同的字符串,具有不同的字体大小。我希望文本在每个TextView. 我怎样才能做到这一点?

这是我的布局:

   <LinearLayout
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:background="@color/colorAccentLight"
            android:textSize="18sp"
            style="@style/Base.TextAppearance.AppCompat.Medium"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="bottom"
            android:textAlignment="gravity"
            android:text="30"
        />
        <TextView
            android:background="@color/colorAccent"
            android:text="hello"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="bottom"
            android:textAlignment="gravity"
        />

    </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是当前的行为,请注意 2 TextViews如何具有不同的基线(“hello”低于 30),因为每个的字体TextView大小不同。

在此处输入图片说明

android textview android-layout android-xml

4
推荐指数
2
解决办法
563
查看次数